我有一个ColumnLayout,其锚点设置为anchor.fill: parent,因此它已经有一个设置维度,这取决于其父维度.
如何添加Rectangles到此中ColumnLayout,从上到下具有特定的间距?
现在我有这个:
ColumnLayout {
anchors.fill: parent
spacing: 2
Rectangle {
height: 50
width: 50
color: "red"
}
Rectangle {
height: 50
width: 50
color: "green"
}
Rectangle {
height: 50
width: 50
color: "blue"
}
}
Run Code Online (Sandbox Code Playgroud)
但是,不是通过间距从上到下使用矩形,2而是将Rectangles均匀地布置在中间ColumnLayout.
一种解决方案是将第一个矩形锚定到父级的顶部,然后将其余的矩形一个接一个地锚定,但我想尽可能避免这种情况.