what is the proper way of reloading qml file to QQuickView? I'm using Qt Quick 2.1 and trying to write a simple program that loads a qml file and displays it. Currently I'm doing it by creating a QQuickView and when i want to reload qml file i am deleting the old one and creating a new one. What is the proper way of doing this? calling QQuickView::setSource with new qml file (or changed qml file) didn't worked for me.
You can use the following (assuming you are in a subclass of QQuickView
):
QUrl tmp = source();
setSource(QUrl());
engine()->clearComponentCache();
setSource(tmp);
You can do it his ways :
Create a main.qml (name can be anything) file, inside which, you will be actually loading and unloading other qml files.
Then use the qml loader element to load/unload (refresh if you may) any other file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With