Align horizontalcenter in Column

24.8k views Asked by At

Column documentation explains how to achieve this:

enter image description here

However, I would like to achieve this:

enter image description here

That is, all items inside the Column should be horizontally aligned to the center. anchors.horizontalCenter: parent.Center does not work. How can I obtain the desired result?

3

There are 3 answers

3
Rudolfs Bundulis On BEST ANSWER

I suppose you can use anchors.horizontalCenter for all the child items to align them with the horizontalCenter of the column given that the column has an id you can refer to.

4
skypjack On

If it's a matter of laying out your items, also take a look at the ColumnLayout component and the attached property Layout.alignment (you can set it as Qt.AlignHCenter).

I find layouts far easier to use.

0
fat On

Try to put this line to every child:

anchors.horizontalCenter: parent.horizontalCenter