[Qt-qml] Rendering of rectangle borders with odd-numbered widths

bea.lam at nokia.com bea.lam at nokia.com
Thu May 6 07:23:31 CEST 2010


Currently if a Rectangle has an odd-numbered width, part of the bottom and right-hand borders are rendered outside the rectangle's boundaries, not inside. This is consistent with Qt's border rendering, as documented at http://doc.qt.nokia.com/4.7-snapshot/qrectf.html (under "Rendering").

This behaviour means that if a Rectangle is drawn inside another Rectangle that has clipping enabled, the inner Rectangle's borders are clipped on the bottom and right-hand sides. If the border width is 1, you will only see the top and left borders of the inner Rectangle.

This can be easily fixed with the attached patch, but obviously it would change the appearance of existing apps. For example if a ListView delegate renders bordered Rectangle elements for each item like this:

Rectangle {
    width: 100; height: 200

    ListModel {
        id: model
        ListElement {}
        ListElement {}
        ListElement {}
    }

    ListView {
        anchors.fill: parent
        model: model
        delegate: Rectangle {
            width: 100; height: 50
            color: "lightsteelblue"
            border.width: 1
        }
    }
}

Currently, there would be a one-pixel horizontal black line between each element, because the bottom border of each element is not visible - i.e. the visible line comes from the top border of the element below (see unpatched.png). If the patch is applied, the bottom borders would be visible, and the horizontal black lines between elements would be two pixels high instead (patched.png). Note that you can still revert to the one-pixel gap by setting "spacing: -1" on the view.

Can this patch be applied? Does anyone foresee significant issues arising from this patch?


Bea

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patched.png
Type: image/png
Size: 565 bytes
Desc: patched.png
Url : http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20100506/73d0073f/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unpatched.png
Type: image/png
Size: 549 bytes
Desc: unpatched.png
Url : http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20100506/73d0073f/attachment-0001.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: application/octet-stream
Size: 1553 bytes
Desc: patch.diff
Url : http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20100506/73d0073f/attachment.obj 


More information about the Qt-qml mailing list