How to make model's property not changing between states when loaded using loader?
-
wrote on 8 Jun 2023, 18:10 last edited by
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.
-
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.
wrote on 8 Jun 2023, 20:31 last edited by@satriyosan you may check if you register the two models with the same name.
-
@satriyosan you may check if you register the two models with the same name.
wrote on 8 Jun 2023, 21:54 last edited by@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.
-
@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.
wrote on 8 Jun 2023, 23:29 last edited by@satriyosan You may show more code to let people help you.
-
@satriyosan You may show more code to let people help you.
wrote on 9 Jun 2023, 00:42 last edited by satriyosan 6 Sept 2023, 00:52@JoeCFD Actually I created post about this but no one replied, so this link contain the code of the problem
Uninteded modified model data -
wrote on 9 Jun 2023, 06:34 last edited by
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.
-
2/6