Please nominate your Qt Champions for 2021!

how do you use QML to changing skins(themes)

  • Hello, everyone!
    I want to use QML for skin change,widgets + qss are easy to implement,but I'm not sure what to do with QML. who can tell me how to do it, thanks

  • Hello! AFAIK, you can create global variables for each element value of your 'appskin' you want to change (width, height, background color/image, etc) for each element ( like button, listview, etc.). The next step is to set values of your elements as they are set in 'global variables', eg:
    Button {
    id: awesomeButton;
    width: yourVarForAwesomeButtonWidth;
    , or something like that. And, the last step is to create a method, which changes global variables, eg load values from 'application skin file' or smth like that. And when you want to change app skin you just call this method with skin name/skinFilePath as a param. And, ofc, don't forget to check values from external skin file for validity. That's all. Hope in helps.

  • Hi,

    Maybe you can try the CSS approach implemented here :

    See video here :

Log in to reply