[solved] ListView from a list variable
-
wrote on 26 Aug 2011, 17:11 last edited by
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.
-
wrote on 26 Aug 2011, 18:31 last edited by
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.
-
wrote on 29 Aug 2011, 15:49 last edited by
Thanks, this is what I needed!
1/3