Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Dynamically change QML theme at runtime

Dynamically change QML theme at runtime

Scheduled Pinned Locked Moved Solved General and Desktop
resourceqml + jstheme
2 Posts 1 Posters 4.1k Views
  • 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.
  • G Offline
    G Offline
    Gregoire Borel
    wrote on 31 Mar 2016, 15:47 last edited by Gregoire Borel
    #1

    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
    0
    • G Offline
      G Offline
      Gregoire Borel
      wrote on 4 Apr 2016, 09:51 last edited by
      #2

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

      1 Reply Last reply
      0

      2/2

      4 Apr 2016, 09:51

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved