Changing QML skins from C++ (like switching daymode <> nightmode)
-
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)
@
- images (images for nightmode)
- day (style.qml with daymode)
- skins
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]
- qml (all "application" qml files are here)
-
Hi guys,
Anyone have a clue?
-
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. -
That's a pretty good idea, I like it! I'm going to try it.
Thanks a lot for your suggestion.