Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.11, 6.3.2, 6.4.0, 6.4.1
-
None
-
Windows 11
Description
When a ColumnLayout is resized by changing the window size it sometimes has a sub-pixel gap between items.
This looks like QTBUG-41216 except I cannot reproduce QTBUG-41216, but using almost identical code I can reproduce this issue with the code below. Click the window content and the line appears.
Window { id: root width: 640 height: 480 visible: true title: qsTr("Sub-pixel Gap in ColumnLayout") ColumnLayout { anchors.verticalCenter: parent.verticalCenter width: root.width spacing: 0 Rectangle { Layout.alignment: Qt.AlignHCenter Layout.preferredHeight: root.height * 0.8 // Math.round(root.height * 0.8) Layout.preferredWidth: root.width * 0.55 color: "red" } Rectangle { Layout.alignment: Qt.AlignHCenter Layout.preferredHeight: root.height * 0.1 // Math.round(root.height * 0.1) Layout.preferredWidth: root.width * 0.55 color: "blue" } } MouseArea { anchors.fill: parent onClicked: root.height -= 0.5 } }
Using `Math.round()` eliminates the gap.
I found this while testing a StackOverflow question. What struck me is that the poster's code that rounds the height of the elements prevents the gap from appearing, which leads me to wonder if the cause is a rounding error like QTBUG-41216.