Qt 6.11 is out! See what's new in the release
blog
[solved] ListView from a list variable
QML and Qt Quick
3
Posts
2
Posters
2.2k
Views
1
Watching
-
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.