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. Skin Qt controls
Forum Updated to NodeBB v4.3 + New Features

Skin Qt controls

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 6.9k Views 1 Watching
  • 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.
  • C Offline
    C Offline
    chcw
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Search the documentation. There are 3 basic ways:

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

      (Z(:^

      1 Reply Last reply
      0
      • C Offline
        C Offline
        chcw
        wrote on last edited by
        #3

        Hi,

        Thank you so much.

        I get the following links:

        1. For QSS: http://qt-project.org/doc/qt-4.8/stylesheet.html . And QSS is using a stylesheet like CSS to define the look & feel of the controls.

        2. For QStyle: http://qt-project.org/doc/qt-5.0/qstyle.html . 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.

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          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.

          (Z(:^

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • C Offline
              C Offline
              chcw
              wrote on last edited by
              #6

              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 .

              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