Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QIcon supports no "pressed" state (QToolButton)?
qwasder85 last edited by qwasder85
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?
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.
qwasder85 last edited by
@SGaist Well, QToolButtons do have a "pressed" state, it works with QSS. Too bad QIcons lack that, that's an oversight IMO.
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.