avb
avb

Reputation: 1751

Align horizontalcenter in Column

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?

Upvotes: 16

Views: 27634

Answers (3)

fat
fat

Reputation: 7133

Try to put this line to every child:

anchors.horizontalCenter: parent.horizontalCenter

Upvotes: 22

skypjack
skypjack

Reputation: 50568

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.

Upvotes: 5

Rudolfs Bundulis
Rudolfs Bundulis

Reputation: 11954

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.

Upvotes: 11

Related Questions