PDA

View Full Version : QGridLayout or QFormLayout like Grid in QML



travick
22nd December 2012, 18:23
I'm using QML Desktop Components 0.1 with QtQuick 1.1.
I'm wondering how to make in QML layout of items that behaves the same as QGridLayout or QFormLayout.
There is Grid, but items within it don't scale to fill the grid.

I need to make form like layout so there are labels and text fields. Text fields should resize to fill parent (window resize).
There anchors, but for eg, i have 20 text areas with labels and I don't want to set anchor for every single item ... It's not efficient.

How to do that properly with QML?

wysota
23rd December 2012, 01:01
Grid should work fine. Just make sure you anchor it properly.

travick
23rd December 2012, 01:07
Unfortunately not: https://qt-project.org/doc/qt-4.8/qml-grid.html#limitations
When I'm using anchors warnings are printed in console and not always everything works as it should ...

wysota
23rd December 2012, 01:52
You can always do something like this:

Rectangle {
width: 360
height: 360
Column {
id: c1
width: 0.5*parent.width
anchors.left: parent.left
Rectangle { color: "red"; height: 200; width: parent.width}
}
Column {
id: c2
anchors.left: c1.right
anchors.right: parent.right
Rectangle { color: "blue"; height: 200; width: parent.width }
}
}