Important: Please read the Qt Code of Conduct -

Skin Qt controls

  • If using the pure Qt technology, not QML, how to skin the controls look & feel with some pictures? Is there a sample to show how to do this?

  • Moderators

    Search the documentation. There are 3 basic ways:

    • use QSS (Qt Style Sheets)
    • use QStyle
    • subclass controls and provide custom widget painting

  • Hi,

    Thank you so much.

    I get the following links:

    1. For QSS: . And QSS is using a stylesheet like CSS to define the look & feel of the controls.

    2. For QStyle: . It seems that QStyle is an abstract class and I need to derive sub-classes from it, or customerize by setting its properties directly.

    3. I understand that.

    Now I am trying to compare the above three methods. I just wonder if I want to seperate the Skin/Skin Resources(such as the images of the controls), with the programming logic. Which method will be the best? I guess it is QSS. But not very sure. Since I am just beginning learning and understanding all of these, which seems to be complex and huge.

  • Moderators

    Yeah, Qt is almost 2 decades old, so this should come as no surprise :-) Take your time, if you have it, and learn step by step. I would recommend QSS for a start, once you have that you can experiment (those methods can be mixed). QSS is quite easy to get into, and although it has some caveats (performance, it's difficult to override once a stylesheet is set), it's worth checking out.

  • Note that mixing style sheets and QStyle (plugins) is not supported: there is no API that tells you what style sheet attributes apply to what widget. That means that you'd have to manually parse and evaluate the whole style sheet set (all the way from the QApplication down to your widget) to know what the style to apply is for your widget in your custom style. I would not recommend this route...

    I'd say, styling approaches are either/or: either you use style sheets, or you use QStyle.

  • OK. I see. Thank you so much. I will try style sheet, since it seems to be similart to CSS, which I am familiar with .

Log in to reply