-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5.9, 6.8.4, 6.10.0 Beta3
-
Windows 10 22H2, MSVC 2022 x64
Code
import QtQuick import QtQuick.Layouts Window { id: window width: 400 height: 300 visible: true function report(item, fillHeight, preferredHeight) { console.log("###", item, "###") console.log("Layout.fillHeight:", fillHeight) console.log("Layout.preferredHeight:", preferredHeight, '\n') } component ExpandingRect : Rectangle { Layout.fillWidth: true Layout.fillHeight: true color: "cyan" } RowLayout { anchors.fill: parent ColumnLayout { ExpandingRect {} RowLayout { // ~50% of the window's height (Expected) Layout.fillWidth: true Layout.fillHeight: true Item { Layout.fillHeight: true } Component.onCompleted: window.report(this, Layout.fillHeight, Layout.preferredHeight) } } ColumnLayout { ExpandingRect {} RowLayout { // 25px high (Expected) Layout.preferredHeight: 25 Layout.fillWidth: true Item {} Component.onCompleted: window.report(this, Layout.fillHeight, Layout.preferredHeight) } } ColumnLayout { ExpandingRect {} RowLayout { // ~100% of the window's height (NOT Expected) Layout.preferredHeight: 25 Layout.fillWidth: true // Layout.fillHeight: false // <-- This line makes it work as expected, even though it should already be false by default! Item { Layout.fillHeight: true } Component.onCompleted: window.report(this, Layout.fillHeight, Layout.preferredHeight) } } } }
Outcomes
Column | RowLayout's Expected Height | RowLayout's Actual Height |
---|---|---|
Left | ~window.height/2 | ~window.height/2 |
Middle | 25px | 25px |
Right | 25px | ~window.height |
Workaround
Explicitly adding Layout.fillHeight: false gives the right column the expected size.
Notes
The debug output says:
qml: ### QQuickRowLayout(0x2aedb6b5600) ### qml: Layout.fillHeight: false qml: Layout.preferredHeight: 25 qml: ### QQuickRowLayout(0x2aedb6b60b0) ### qml: Layout.fillHeight: false qml: Layout.preferredHeight: 25 qml: ### QQuickRowLayout(0x2aedb6b4c80) ### qml: Layout.fillHeight: true qml: Layout.preferredHeight: -1
...which shows that the workaround should not be required.
Also, even if the RowLayout defaults to Layout.fillHeight: true somehow, the left column shows that the RowLayout should only have half the window's height.