Unsolved How to change and update model of GridView dynamically?
-
Hi;
I have a GridView:
MyGrid.qml
:GridView { id: gridView model: 2 delegate: Rectangle { id: rect width: 70 height: 70 MouseArea { anchors.fill: parent; onClicked: rect.visible = false } } }
model
ofGridView
is2
at the moment. I have this QML file:
MyPopup.qml
:Popup { id: popup background: Rectangle { width: 250 height: 250 color: 'red' Button { id: btn onClicked: { gridView.model = gridView.model * 2; // I changed model popup.close(); // Then I closed popup } } } }
This popup is opening if visibles of all rectangles are
false
.
I changed model of GridView but whenpopup
closed, I can't see any on the screen. Because there is still GridView with its old model (and you remember, visibles of rectangles arefalse
).
I want when model of GridView changed, I saw new GridView with its new model. How can I do it? Thanks. -
HI @Ibrahim
There are many ways to do it.
You might be creating MyGrid and MyPopup in some qml file. Usegird.gridView.model
instead ofgridView.model
inside popup button onclick.property int girdSize: 2 Mygrid{ id: grid } MyPopup{ id:popup }