Using margins combined with layouts
-
Hey all,
I have a UI that features Layouts nested in Layouts (i.e. a RowLayout somewhere within a ColumnLayout, filling width and height).
It would be great if I could use margins alongside, but it doesn't seem to have any effect if I don't use anchors to place the elements.
Is there a little workaround for that or do I have to choose one technique?Following is a little example. How would I go about setting margins for one of the nested Layouts in there?
ColumnLayout { anchors.fill: parent spacing: 0 Rectangle { Layout.fillWidth: true color: "darkblue" height: 35 } RowLayout { Layout.fillWidth: true Layout.fillHeight: true spacing: 5 ColumnLayout { id: centerLeftColumnLayout Layout.fillWidth: true Layout.fillHeight: true Rectangle { Layout.fillWidth: true color: "yellowgreen" height: 30 } Rectangle { id: signalTiles Layout.fillWidth: true Layout.fillHeight: true color: "lightblue" } Rectangle { Layout.fillWidth: true color: "green" height: 50 } } ColumnLayout { Layout.fillWidth: true Layout.fillHeight: true spacing: 0 Rectangle { Layout.fillWidth: true color: "red" height: 30 } Rectangle { Layout.fillWidth: true Layout.fillHeight: true color: "blue" } } } Rectangle { Layout.fillWidth: true color: "orange" height: 40 } }
-