Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why anchors.centerIn doesn't working for Column elements?

Tags:

qt

qml

I have this piece of QML code:

 Column {
     spacing: units.gu(2)
     anchors {
         fill: parent
         centerIn: parent
     }
     Row {
         spacing: units.gu(4)
         ...
     }
     Row {
         spacing: units.gu(4)
         ...
     }
     Row {
         spacing: units.gu(4)
         ...
     }
     Row {
         spacing: units.gu(4)
         ...
     }
 }

I'm trying to center Column in its parent element (a Page element), but it doesn't work. If a try to centerIn: parent in one of the Rows, it works, but as I have 4 Rows, it break the layout. But Rows respond to this, instead my Column.

Why make centerIn: parent works for Column? Theres another ways to center this?

like image 604
ayr-ton Avatar asked Oct 16 '25 01:10

ayr-ton


1 Answers

you can't set 'fill' and 'centerIn', so put column in anchors.centerIn:parent and the Rows in anchors.horizontalCenter:parent.horizontalCenter (centerIn is not allowed cause it conflicts the parent vertical positionning....).

like image 136
TheBootroo Avatar answered Oct 18 '25 22:10

TheBootroo