Column and ColumnLayout are very different, you cannot exchange them easily.
The purpose for which they have been created it’s very different.
Before explaining the difference, it’s important to note the basis on which they are based on.
Before Qt introduced the Qt Quick, there was only QWidget and the way to organize the QWidget was based on QLayout hierarchy. The QLayout is an non-visual object that take the responsability to dynamically change the dimension of the QWidget according to a policy in order to fit all QWidget in a specified dimension.
When Qt introduced the Qt Quick, the ‘anchors’ mechanism was introduced to organize the item into the window. The ‘anchors’ are a quite different approach. There isn’t an intermediate object that dynamically resize the Items, but instead there are constraints the bind the Items to move (and in some case to stretch) depending on how they have been ‘anchored’.
Initially, there was no way to the fan of QLayout to use the same way on Qt Quick. But with Qt Quick 2.0 (I think), Qt introduced a mechanism that mimics the QLayout way to arrange things into the Qt Quick: ColumLayout, etc.
And now back to Colum and ColumLayout.
Column: it’s created to allow an easy way to arrange via ‘anchors’ the children Items into a Column. And then, you cannot explicitly set or bind vertical ‘anchors’ and properties like ‘y’. Because they are under Column control. But width and height properties are under your control and you can bind to whatever you want.
In fact, Column has an height variable depending on the heights of the children.
ColumnLayout: it’s created to mimic the QVBoxLayout, and arrange the Item by dynamically changing the width and the height in order to keep them arranged into a column that fits inside the width and height of ColumnLayout. In this case, the width and the height of items are under the ColumnLayout. You cannot (should) set directly, instead you have to use the Layout attached properties in order to inform ColumnLayout how they should changed. Some of these properties are: Layout.preferredWidth/Height, Layout.minimumWidth/Height, Layout.maximumWidth/Height
ColumnLayout tend to stretch and to shrink the Item in order to keep them into a specified space and also it allow to specify a relative proportion between items in order to achieve an effect that some item are bigger that other: Layout.rowSpan, Layout.columnSpan
So, the code that works with Column doesn’t works with ColumnLayout and viceversa.
Try to understand which one is more suitable for your.
↧








