【发布时间】:2020-11-17 00:54:41
【问题描述】:
我遇到了一个关于布局内组件的顶部/底部边距的问题(此处为 GridLayout,但它似乎与 ColumnLayout 相同)与 fillHeight。
考虑以下示例:
`
import QtQuick 2.0
import QtQuick.Layouts 1.2
Item {
width : 800
height : 480
GridLayout {
anchors.fill: parent
columns: 2
rows : 2
Rectangle {
color:"red"
Layout.fillHeight: true
width : 400
}
Rectangle {
color:"green"
Layout.rowSpan: 2
Layout.fillHeight: true
width : 400
}
Rectangle {
color:"blue"
Layout.fillHeight: true
width : 400
Layout.bottomMargin: 10
}
}
}
` 显示为。
只需注释“Layout.bottomMargin: 10”行即可重新建立红色和蓝色矩形之间的比例:
当我猜测它不应该时,似乎有一个比率考虑了边距。事实上,蓝色矩形的高度似乎是(上边距+下边距)*红色矩形的高度(我已经用十几个值进行了测试,可能还不够)。
【问题讨论】: