How to make model's property not changing between states when loaded using loader?
-
I have two distinct QAbstactListModel object exposed to QML , each tied to two distinct Repeater. When I switch views between two states, the model data on the second view was unintendedly copied from first view. I have tried to use standard role for accessing those data but still same. Are there any possibilities of clashing name when loading process happened? However, I made both modelname property distinct , and I print both object has difference memory locations. Help me guys.
-
@satriyosan you may check if you register the two models with the same name.
-
@JoeCFD I use setContextProperty method to register python object to qml. I've check that I use two different name when registering
engine.rootContext().setContextProperty("channelmodel1", mymodel1) engine.rootContext().setContextProperty("channelmodel2", mymodel2)
I created button to change both model data in one view, and everything was okay, each repeater changed it's own data. But only when I switch view then channelmodel2 data changed like mirrored to the channelmodel1 data.
In the second view , when i pressed button , everything is okay, each repeater changed it's own data separately. The only problem is when the switching happen
Btw I used states property of Rectangle to switch between loader item which consist each model.
-
@satriyosan You may show more code to let people help you.
-
@JoeCFD Actually I created post about this but no one replied, so this link contain the code of the problem
Uninteded modified model data -
I solved it. It turns out, I uses same listdata to both models, I need to make new listdata, and pass it to the second model. So models don't share same list data. problem solved.
-