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. QToolButton setStyleSheet sets stylesheet on tooltip
Forum Updated to NodeBB v4.3 + New Features

QToolButton setStyleSheet sets stylesheet on tooltip

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 14.0k 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.
  • S Offline
    S Offline
    Soerenc
    wrote on 17 Mar 2011, 11:41 last edited by
    #1

    Hello

    I have a problem with a QToolButton. It is placed on a dark background, so the button textcolor is set to white with the stylesheet
    @helpButton->setStyleSheet("color: white;");@

    And it works great. The problem is, that the button also has a tooltip, but now the textcolor of the tooltip is also set to white, but the tooltip background is almost white, so the text is not visible.

    My question is, how do I set a stylesheet on my button that sets the textcolor to white, but keeps the original tooltip textcolor?

    I have tried
    @helpButton->setStyleSheet("QToolButton{ color: white;}");@
    and
    @helpButton->setStyleSheet("color: white; QToolTip{ color: black;}");@
    And other variations, but without the desired effect.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on 17 Mar 2011, 12:03 last edited by
      #2

      You could try to use the decendant selector:
      @
      QToolButton { color: white;}
      QToolButton QWidget { color: black;}
      @

      I am using QWidget, because I don't know of what class the actual popup is. It is not QToolTip; the actual class seems to be private.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giesbert
        wrote on 17 Mar 2011, 12:04 last edited by
        #3

        so, the first solution sets the color for everything to white. And style sheets are used in child widgets as well, so for the first version, the result is clear.

        But the second one should work.

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Soerenc
          wrote on 17 Mar 2011, 12:15 last edited by
          #4

          I tried
          @helpButton->setStyleSheet("QToolButton { color: white;} QToolButton QWidget { color: black;}");@
          and it works perfectly. Thank you for a fast and great solution :)

          1 Reply Last reply
          0

          4/4

          17 Mar 2011, 12:15

          • Login

          • Login or register to search.
          4 out of 4
          • First post
            4/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved