Dynamically change QML theme at runtime
Gregoire Borel last edited by Gregoire Borel
I'm actually using the solution provided here: http://stackoverflow.com/a/25864815/2425044
I'd like to get rid of the import "MyTheme.js" as Theme; statement in order to dynamically load a specific theme at runtime (usually chosen by the user).
What I'm currently doing is loading each of my Themes.js files in a qrc file:
redTheme.qrc contains Theme.js
blueTheme.qrc contains Theme.js
These qrc files are compiled into external binary resources (rcc) and loaded from the binary directory, using
registerResource(const QString &rccFileName, const QString &mapRoot = QString())
So far, everything works. The only problem is that I'm stuck with an import statement in my QML files:
import "qrc:/redTheme/Theme.js" as Theme
Thus, despite registering blueTheme.rcc as a resource, it will never be used.
Gregoire Borel last edited by
Solution can be found here: http://stackoverflow.com/questions/36335481/dynamically-change-qml-theme-at-runtime/36399339#36399339