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. QPushButton - not working setIcon in Active state

QPushButton - not working setIcon in Active state

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.7k 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.
  • D Offline
    D Offline
    dr.ew
    wrote on last edited by
    #1

    QIcon icon;
    icon.addFile(":/25.png", QSize(), QIcon::Normal); - ok
    icon.addFile(":/25_hover.png", QSize(), QIcon::Active); - fails
    icon.addFile(":/25_disabled.png", QSize(), QIcon::Disabled); - ok

    QPushButton button;
    button.setIcon(icon);

    When mouse hover the button (button is Active), but icon of the button in state Normal, why?

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      The Active state can mean different things for different widgets. For push button hover and active are two different things. A button becomes active when it has focus (e.g. after a click or via keyboard tabbing to it). Hovering is not the same as it can occur over an inactive button too.
      To style a button when mouse hovers over it you can use a stylesheet.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dr.ew
        wrote on last edited by
        #3

        Chris, thank you!

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dr.ew
          wrote on last edited by
          #4

          [quote author="Chris Kawa" date="1423590349"] A button becomes active when it has focus (e.g. after a click or via keyboard tabbing to it). Hovering is not the same as it can occur over an inactive button too.[/quote]

          Sorry, Chris, do you know when QCheckBox becomes Active?

          1 Reply Last reply
          0
          • Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by
            #5

            bq. do you know when QCheckBox becomes Active?

            An intuition would suggest the same situation - clicked or navigated via keyboard, but apparently it doesn't respect the icon change on that soo... I don't know. Possibly a Qt bug?

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dr.ew
              wrote on last edited by
              #6

              Finally, I haven't could learn, when QCheckBox becomes Active and solved the problem via inheritance from QCheckBox.

              Stylesheet for QCheckBox is very limited.

              Thank you for help!

              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