gpt4 book ai didi

layout - QML GridLayout 跨度

转载 作者:行者123 更新时间:2023-12-04 19:47:40 31 4
gpt4 key购买 nike

如何使洋红色矩形比红色矩形短 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
}
}

http://i.stack.imgur.com/nHfmB.gif

最佳答案

Layout.fillHeight是问题所在;它试图尽可能高。相反,设置 Layout.preferredHeight到第一列所需的高度。此外,当您为每个 Rectangle 指定行和列时,无需更改流程。 -- 使用 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"
}
}

关于layout - QML GridLayout 跨度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24674086/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com