Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

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

    General and Desktop
    2
    4
    15666
    Loading More Posts
    • 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
      coyotte508 last edited by

      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 Reply Quote 0
      • A
        andre last edited by

        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 Reply Quote 0
        • C
          coyotte508 last edited by

          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 Reply Quote 0
          • A
            andre last edited by

            Good to know, and thanks for providing your solution!

            1 Reply Last reply Reply Quote 0
            • First post
              Last post