[solved] ListView from a list variable
-
Hi,
I need to create a ListView which would contain items defined in a list variable. Lets say I have a variable called "fruits", which contains "orange", "apple", "pear" and "kiwi". Now I want to create a ListView which would contain Text items with these fruits. Of course I expect that if I change the variable "fruits" (delete "apple", for example), the ListView will change as well.
I can do this using PySide, but this time I would like to stay with QML only, not requiring Python. How should I do this?
Thank you.
-
You can set ListView`s model to "ListModel":http://doc.trolltech.com/4.7/qml-listmodel.html . ListModel has functions for add/remove items from it. All changes are automaticaly updated in ListView.