[Qt-qml] Advanced layout support
Adriano Rezende
adriano.rezende at openbossa.org
Mon Oct 17 03:09:45 CEST 2011
Hi,
I'm moving a layout discussion to this mailing list.
I've pushed an initial version of a linear layout element in the
following branch:
http://qt.gitorious.org/~arezende/qt-components/arezende-desktop/commits/layouts
It basically provides more powerful layout management than Row/Column
elements, since it handles item stretching, individual item spacing,
minimum/preferred/maximum size policies.
These are mandatory features in most of the desktop applications and I
think they should be addressed in a proper manner. Currently, we end
up simulating such features using a lot of anchors and property binds
that increases the code size and impacts in performance.
The current implementation provides a RowLayout and a ColumnLayout element.
Follows an example:
RowLayout {
spacing: 10
Item {
Layout.spacing: 6
Layout.minimumWidth: 100
}
Item {
Layout.maximumWidth: 300
Layout.stretchFactor: 2.0
}
}
There are some features in the TODO list, like accepting different
size policies and some improvements in the layout behavior.
I would like to get a feedback about this API, suggestions or any
extra feature that would make sense to add.
Regarding QtQuick2, I would like to bring to discussion if such
support should be added for the Row, Column and Grid elements. That
would provide a better integration with QtCreator.
As a suggestion, we could handle more complex use cases like the following:
Row {
spacing: 10
Item {
Row.spacing: 5
Row.sizePolicy: Row.Fixed
}
Item {
Row.maximumWidth: 300
Row.stretchFactor: 2.0
Row.sizePolicy: Row.Expanding
}
}
If one wants to use the default Row/Column features, no attached
properties would be needed. The same would be applied for Grid, like
span support.
Cheers,
Adriano
More information about the Qt-qml
mailing list