3

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?

4

1 回答 1

9

你不能设置'fill'和'centerIn',所以把列放在anchors.centerIn:parent中,把Rows放在anchors.horizo​​ntalCenter:parent.horizo​​ntalCenter中(centerIn是不允许的,因为它与父垂直定位冲突......) .

于 2013-06-27T06:54:46.283 回答