Can a QML file refresh a JS import at runtime?
-
Is there a way to have a QML file re-import a JS file at runtime? For example, I have this line at the top of a QML file:
@import "qrc:/someJSfile.js" as MyJS@
Now, suppose new functions are added, or existing functions are edited in that JS file while the Qt app is running. Javscript is a dynamic language that offers runtime evaluation, but I wonder how I could have the QML file "refresh" its knowledge of those functions without restarting the app?
-
Yes.
use Qt.Include()
see "this":http://qt-project.org/doc/qt-5/qtqml-javascript-imports.html#including-a-javascript-resource-from-another-javascript-resource