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. QIcon supports no "pressed" state (QToolButton)?

QIcon supports no "pressed" state (QToolButton)?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 600 Views
  • 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.
  • qwasder85Q Offline
    qwasder85Q Offline
    qwasder85
    wrote on last edited by qwasder85
    #1

    I recently changed some older code that used a stylesheet to change the states of the icons on a QToolBar to use QIcons applied to the QActions instead (so I have the icons wherever the actions are in use).
    This works fine until I need an icon state for "pressed". There is a "pressed"-state of a QToolButton in the stylesheet, but none for a QIcon.
    The only states (they call it "modes") of QIcons are: Normal, Disabled, Active, Selected. None of those apply when I hold the mouse button down on the QToolButton.

    Does anyone know a workaround or little hack for tackling this issue?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Because icons have no such state and it would not make sense for them to have one.

      The pressed state is something that is only of concern for buttons. AFAIK, there's no workaround, change the icon for the pressed state.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      qwasder85Q 1 Reply Last reply
      2
      • SGaistS SGaist

        Hi,

        Because icons have no such state and it would not make sense for them to have one.

        The pressed state is something that is only of concern for buttons. AFAIK, there's no workaround, change the icon for the pressed state.

        qwasder85Q Offline
        qwasder85Q Offline
        qwasder85
        wrote on last edited by
        #3

        @SGaist Well, QToolButtons do have a "pressed" state, it works with QSS. Too bad QIcons lack that, that's an oversight IMO.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Wouldn't that pressed state map to QIcon's on state ?

          Mode and State are two different things in QIcon. The first one is for the intended use e.g. if you disable a button whether it's pressed or not, it should still show as disabled. The second matches more closely the "active" / "inactive" nature of a pressed and released button which looks like what you are looking for.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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