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. [SOLVED] Stylesheets: Giving a different color to the checkbox indicator than the text
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Stylesheets: Giving a different color to the checkbox indicator than the text

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 17.2k 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
    coyotte508
    wrote on last edited by
    #1

    Hello all!

    I've been using css with qt, and it's pretty wonderful. However I came across a problem.

    If you use that:

    @
    QCheckBox {
    color: white;
    }
    @

    For example, you have a black background and so you want to have white text... The problem is that the checkbox indicator becomes white too, instead of staying black, and white on white is invisible (I'm using plastique style).

    Here is an example in how that looks in my app:

    !http://i42.tinypic.com/v5imgg.png(dark theme)!

    (Full picture "here":http://i43.tinypic.com/aca7h1.png)

    If I do:

    @
    QCheckBox::indicator {
    color: black;
    }
    @

    Then the indicator becomes Windows-CE like on windows, it's really bad. And it has no effect on ubuntu.

    So is there a way to do this that I don't know about? Or, where are the indicators stored, so I can do something like:

    @
    QCheckBox::indicator {
    background: url(...);
    }
    QCheckBox::indicator:hover {
    background: url(...);
    }
    QCheckBox::indicator:checked {
    background: url(...);
    }
    QCheckBox::indicator:pressed {
    background: url(...);
    }

    QCheckBox::indicator:hover:checked {
    background: url(...);
    }

    @

    Even if it's a bit tedious.

    Thanks!

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

      I don't think the indicator is available by default as an image. QStyle offers the StandardPixmap enum, but I don't spot a checkbox indicator in there. However, if you just use your own image (a screenshot can help you get one), you should be able to follow the Styling QCheckBox example from the Qt Style Sheets Examples page. You can simply use the image property (not the background) property for the check mark.

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

        Well thanks it worked!

        For those who have the same problems, the icons are there: http://www.mediafire.com/file/7alp9uzvul6vw11/check-icons.zip

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

          Good to know, and thanks for providing your solution!

          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