A very strange problem for List View and loader
-
Hi everyone,
I encounted a very strange problem, which is decribed below:
I have a loader, which loads different qml files. for example:
two qml files:
A.qml
B.qml
in B.qml, there is a ListView:
@Rectangle{
width:360
height:640
ListView{
anchors.fill:parent
model:MyModel{}
Delegate: myDeletage
}
} @First, i load B.qml, then i load A.qml. Now, i changed MyModel.qml, and then reload B.qml. but the listview is the same as before. it is not changed according to new model.
I dont know why it is, because loader is for creating objects dynamically. It destroys the previous object totally, isn't it?
Thanks in advance
-
This is likely due to the parsing of MyModel.qml being cached (the engine doesn't expect/handle .qml files changing on-the-fly). I can't think of any easy workarounds at the moment; you'll likely need to restructure the model handling somehow (using a C++ model; or keeping MyModel persistant and manipulating it from QML, rather than rewriting the file; or passing different models into B through e.g. a property alias).
Regards,
Michael -
Thank you very much Michael,
I understand, i will try to restructure the application.
[quote author="mbrasser" date="1301008595"]This is likely due to the parsing of MyModel.qml being cached (the engine doesn't expect/handle .qml files changing on-the-fly). I can't think of any easy workarounds at the moment; you'll likely need to restructure the model handling somehow (using a C++ model; or keeping MyModel persistant and manipulating it from QML, rather than rewriting the file; or passing different models into B through e.g. a property alias).
Regards,
Michael[/quote]