Open JanisErdmanis opened 3 months ago
The clearComponentCache
approach is also used in qhot
which seems to be activelly. maintained as can be seen here.
Thanks, I share your frustration and didn't know about this solution. Exposing clearComponentCache
should be easy, I'll take a look.
Thanks for suggesting this, it is now sort of working, to be demoed tomorrow at JuliaCon ;)
While developing UI features in QML for my application, I got frustrated with the current workflow because it requires restarting the QML application to see changes. This is exacerbated by my window manager, who decides to place the created application randomly between different screens.
A solution to this would be implementing live reloading. I have been following the approach outlined in https://qml.guide/live-reloading-hot-reloading-qml. The technique primarily involves using Loader extensively to reload the components dynamically.
However, a major obstacle with this approach is related to how QML manages caching. QML caches loaded objects based on their filenames, meaning reloading the same file doesn’t reflect any changes made to it. To update the cache and see the changes, the component cache needs to be cleared first. Unfortunately, the necessary function QQmlEngine::clearComponentCache() is not currently exposed.
I also tried to make a workaround by adding a url parameter to the cache like:
which worked but did not reload components on which the circle itself depended; thus, it’s a dead end.
If
QQmlEngine::clearComponentCache
would be exposed by QML, I could implement a qmlfunctionJulia.clearCache()
, which would allow me to integrate live reloading in my workflow. Tracking QML source files and updating the view would be something I could also explore if theclearComponentCache
would be exposed.