Possible to update/refresh Flow QML component when item has been removed?
-
I have a Flow layout where I add items dynamically on user actions. In the same way I remove these items on user actions. The Flow QML component seems to work as expected until an item is removed. The item itself is removed, but the space it occupied is just blank. My intuition tells me the graphical item itself got deleted, but the view is not updating when items are removed.
Is the dynamical deletion of child items outside the scope of the Flow Component? Is there any other layout that behaves equally? GridLayout seems to be the closest, but it does not automatically wrap child items when the layout is resized.
Is there any non-hack way to enable Flow to rearrange when child item is disabled? If not, and if GridLayout is my best shot, how to make it wrap its child items like Flow does?
-
I have a Flow layout where I add items dynamically on user actions. In the same way I remove these items on user actions. The Flow QML component seems to work as expected until an item is removed. The item itself is removed, but the space it occupied is just blank. My intuition tells me the graphical item itself got deleted, but the view is not updating when items are removed.
Is the dynamical deletion of child items outside the scope of the Flow Component? Is there any other layout that behaves equally? GridLayout seems to be the closest, but it does not automatically wrap child items when the layout is resized.
Is there any non-hack way to enable Flow to rearrange when child item is disabled? If not, and if GridLayout is my best shot, how to make it wrap its child items like Flow does?
If I understand you right, it is definitely not so for me.
E.g. this works fine:
Qt 5.7.1ListModel { id: mm } Flow { width: parent.width spacing: 10 Repeater { model:mm delegate: Rectangle { width: 100 height: 50 color: "grey" } } } Column { anchors.right: parent.right Button { text: "Add" onClicked: { mm.insert(0, { "name": "Item " + mm.count }) } } Button { text: "Remove" onClicked: { mm.remove(1, 1) } } Button { text: "Move" onClicked: { mm.move(1, 3, 1) } } }
-
Roumed is correct as far as I can see. I also posted this question on StackOverflow.com and the answer provided there can be helpful as well: StackOverflow Question