Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Solved Dynamically change QML theme at runtime

    General and Desktop
    resource qml + js theme
    1
    2
    3257
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Gregoire Borel
      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.

      1 Reply Last reply Reply Quote 0
      • Gregoire Borel
        Gregoire Borel last edited by

        Solution can be found here: http://stackoverflow.com/questions/36335481/dynamically-change-qml-theme-at-runtime/36399339#36399339

        1 Reply Last reply Reply Quote 0
        • First post
          Last post