How to clean ListModel data from a ListView, when model changes?[SOLVED/not an issue]
-
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 }
}@
-
I tried your example, it works well for me. When I push the button it changes the model and refresh the view.
I work with Qt 4.7.1 Linux. -
It works well. Windows XP machine with Nokia Qt SDK 1.1.
-
Hmm wierd, seems like my laptop is slow or I messed the big code a bit...I will dig a bit further before maring this as SOLVED/not an issue...
UPD: thanks for your replies! - indeed its my slow PC that caused some graphics glitches...the code works