01-03-2013 03:51 AM
I have a ListView displaying some favorites to my user. I want to have two different representations of these favorites the user can choose between with a button. So I think I should just change the listItemComponents property of my ListView at run time. But so far, as I haven't found a way to store a ListItemComponent on a variable, I don't see how I can achieve this. I would like to avoid to have two ListView, one shown and one hidden.
Solved! Go to Solution.
01-09-2013 05:10 AM
You could reuse the same ListView, but with two different ListItemComponents (one for each view). One ListItemComponent handles the items of itemType "view1", the other of "view2".
When a user selects another view, just change the itemTypes returned by the DataModel.
01-09-2013 07:25 AM
I don't see how, it would be better to make a method in your DataModel that is invokable from QML (mark it with Q_INVOKABLE). That method then can just toggle between the views and signal that the datamodel has new data for the listview.