How to clean ListModel data from a ListView, when model changes?[SOLVED/not an issue]
QML and Qt Quick
4
Posts
3
Posters
3.1k
Views
1
Watching
-
Hi all, I was experimenting further with ListViews and recently found the following:
- if a ListView has rendered ListModel, changing ListView.model to a new model doesn't "clear" the data from the previous model. Meaning in my example below though new model contains only "Cow" you still see the "Cat".
Is there a way to clear the view?
@import QtQuick 1.0
Item {
width: 200; height: 250ListModel { id: myModel ListElement { type: "Dog"; age: 8 } ListElement { type: "Cat"; age: 5 } } ListModel { id: myModel2 ListElement { type: "Cow"; age: "3" } } Component { id: myDelegate Rectangle { id: rect3 width: 300 height: 300 Text { text: type + ", " + age } Text { text: "BUTTON" y: 50 MouseArea { anchors.fill: parent onClicked: myview.model = myModel2 } } } } ListView { id: myview anchors.fill: parent model: myModel delegate: myDelegate }
}@
-
It works well. Windows XP machine with Nokia Qt SDK 1.1.
-