Changing model for a ListView
-
Hi everyone,
I got a ListView and some models for it. Each model is in independente QML files.
I use
@model: MyModel1{} @to intitialize the model for the view.
My question is: when i want to changing models, (for example, there is a button doing it ), i cant use
@OnClicked:{
myList.model=MyModel2{}
}@there is going to be an error, How can i do it?
Ps, I can't write all the model in the ListView 's QML file, because i want a dynamical way to change model, and i dont know i will have my many models at the beginning.Thanks
-
-
Thanks Andre,
I changed the structure of my application: i used QML to create a ListModel before, it was not that convinent, because my application is very dynamic. Now, I create models using Qt/C++, and expose the model to QML.
[quote author="Andre" date="1301318630"]Could you use a Loader component then?[/quote]