How can I make the magenta rectangle to become 6 times shorter than the red rectangle?
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
}
}
The
Layout.fillHeight
is the problem; it tries to be as tall as possible. Instead, setLayout.preferredHeight
to the desired height for the first column. Also, it is not necessary to change the flow when you specify the row and column for eachRectangle
-- useLayout.alignment
to fill from the top: