Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Changing QML skins from C++ (like switching daymode <> nightmode)
QtWS25 Last Chance

Changing QML skins from C++ (like switching daymode <> nightmode)

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 4.7k 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.
  • B Offline
    B Offline
    bkamps
    wrote on last edited by
    #1

    Hi,

    In my application I want to use skins (like daymode and nightmode). Switching a skin needs to be done from C++. In my application I also use images.

    I want to create directories as follows:

    @

    • qml (all "application" qml files are here)
      • skins
        • day (style.qml with daymode)
          • images (images for daymode)
        • night (style.qml with nightmode)
          • images (images for nightmode)
            @

    The style.qml files contains a QtObject with all the skin related properties needed by the QML "application". It also contains a name of the skin so when an image has to be loaded the name of the skin can be used to load this image from the correct skin directory.

    The user can flip a hardware button (embedded device) and another skin should be visible.

    I have read "this guide":http://developer.qt.nokia.com/wiki/QmlStyling .Is this the best approach? And how can I change the skin? Maybe by loading another style.qml?

    [EDIT: code formatting for the "list", Volker]

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bkamps
      wrote on last edited by
      #2

      Hi guys,

      Anyone have a clue?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Slocan
        wrote on last edited by
        #3

        I would approach this by using something like Qt.createComponent(skin+"/style.qml");
        where skin is a string with the name of you skin. This creates your style component, based on the current skin, that you can use in your application.
        I haven't tried it myself, and it might not be the best way to do it, but I guess it's a start.

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bkamps
          wrote on last edited by
          #4

          That's a pretty good idea, I like it! I'm going to try it.

          Thanks a lot for your suggestion.

          1 Reply Last reply
          0

          • Login

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