如何使洋红色矩形比红色矩形短 6 倍?
GridLayout {
id: gridLayout
anchors.fill: parent
flow: GridLayout.TopToBottom
Rectangle {color: "magenta"
Layout.row: 0
Layout.column: 0
Layout.fillHeight: true
Layout.fillWidth: true
Layout.rowSpan: 1
}
Rectangle {
Layout.row: 0
Layout.column: 1
color: "red"
Layout.rowSpan: 6
Layout.fillHeight: true
Layout.fillWidth: true
}
}
https://i.stack.imgur.com/nHfmB.gif https://i.stack.imgur.com/nHfmB.gif
The Layout.fillHeight
是问题所在;它试图尽可能高。相反,设置Layout.preferredHeight
到第一列所需的高度。此外,当您为每个指定行和列时,无需更改流程。Rectangle
-- use Layout.alignment
从顶部填充:
GridLayout {
id: gridLayout
anchors.fill: parent
Rectangle {
Layout.row: 0
Layout.column: 0
Layout.fillWidth: true
Layout.preferredHeight: parent.height/6
Layout.alignment: Qt.AlignTop
color: "magenta"
}
Rectangle {
Layout.row: 0
Layout.column: 1
Layout.fillHeight: true
Layout.fillWidth: true
color: "red"
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)