I'm using QtQuick 1.1 with Qt 4.8 on an embedded Linux Plattform. I have somekind of Desktop where dynamically created Rectangles are arranged in a Grid - this Grid is inside a Flickable.
Flickable{
anchors.fill: parent
contentHeight: homegrid.height
flickableDirection: Flickable.VerticalFlick
clip:true
Grid{
anchors.left: parent.left
anchors.top: parent.top
columns: 4
flow: GridView.LeftToRight
id: homegrid
//new items get pushed to this grid
}
}
It looks like this:
When i create 2 more items, i push them to the end of the grid which looks like this:
Taht's my current State. But now i need to get categories in this Grid and i need to be able to push new items to each category. Should look like:
And after adding two items to the red category:
How can i arrange containers in a grid where the containers automatically break at the end of each row?
Solution:
- Using a GridView
GridView{
model: myDesktopModel
delegate: HomeLinkeDelegate { id: homeLinkDelegate }
}
- defining the list in c++
QList<QObject*> objectList;
The List can be sorted (by Colors).
- Register the List
viewer->rootContext()->setContextProperty("myDesktopModel",QVariant::fromValue(this->objectList));
When the List is modified, you have to register it again - than the GridView refreshes.
More information about GridView: http://doc.qt.io/qt-4.8/qml-gridview.html#model-prop
More information about QObjectList-based model http://doc.qt.io/qt-4.8/qdeclarativemodels.html#qobjectlist-based-model




Grid, no additional code is needed. - GrecKo