Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Does this program kill the main window everytime that reload() function called? #2

Open
LinArcX opened this issue Jun 20, 2019 · 2 comments
Labels

Comments

@LinArcX
Copy link

LinArcX commented Jun 20, 2019

I see that every little change will cause the app to restart. is it right?
I also follow another idea to hot-reload qml files:
https://qml.guide/live-reloading-hot-reloading-qml/
He uses Loader component and clearComponentCache() function in c++ side to re-evalute qml files.
But i can't successfully run his sample app to see the actual behavior.
Imagine our app is very big and every time restart whole app isn't very efficient. so the ability to re-load some parts of a qml page would be very awesome.
Is there any way to do it via runtimeqml?

@GIPdA
Copy link
Owner

GIPdA commented Jun 20, 2019

It is not the whole app per say that is reloaded, but the whole QML part of it. All windows are closed and deleted and the main QML file is reloaded. All C++ stuff is not touched. Of course it depends on what you do in your QML, you should put all logic & states into C++ for it to work properly.
Reloading the full QML every time is pretty fast even with large codebases.
AFAIK there is no possibility to reload only some QML files.

You can of course use a Loader for that, but it adds an extra layer and Loaders are sometimes finicky to use (properties, bindings and stuff). And that extra layer stays here even in release builds. RuntimeQML can be completely removed very easily with a simple #ifdef.

I looked at the link you posted, interesting stuff. I'm not sure what effects calling QQmlEngine::clearComponentCache() would have on other still loaded components though, but I guess nothing bad? Testing is required :P
Note that the loader only reloads itself, other loaders using the same QML file would also need to be reloaded.
And mixing with the QRC would also require extra work getting the paths right. RuntimeQML is transparent with that, no need to adapt anything for it to work (unless when using a file selector).

Personally I don't want to get any dev-only related stuff to creep in the QML because you can't easily get rid of it. And as I said, reloading everything is very fast, so having the ability to reload only a specific part is not very useful, especially if it depends on an extra Loader (a big no-no for me).

If your app can't be reloaded, you're doing it wrong ;)

Hope that helps!

@GIPdA GIPdA added the question label Jun 20, 2019
@LinArcX
Copy link
Author

LinArcX commented Jun 20, 2019

Thank you so much for explanations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants