Styling QPushbutton with a Popup QDockWidget
I have set the icon for one of my QPushButtons using the Qt standard icons (as an aside, how do I do this in Designer?)
Code:
ui
->pushButton
->setIcon
(qApp
->style
()->standardIcon
(QStyle::SP_ArrowRight));
My desired functionality is to have the button pop up a QDockWidget while clicked/checked, then have it close the QDockWidget when clicked again. The button should be in a depressed state while the dock widget is open and should appear normal when the widget is closed.
Does this functionality already exist somewhere in another widget, or do I need to recreate it somehow? If I need to recreate it, how do I access the greyed-out version of the standard icon? Basically, I'd like to set the button to appear disabled, but still function as if it's enabled. Is that possible?
Re: Styling QPushbutton with a Popup QDockWidget
1. to set button pressed you should:
- setCheckable(true);
2. to change icon in different states (normal, hover, pressed) you can inherit you class from QPushButton or you can use style sheets (see http://doc.qt.io/qt-4.8/http://doc-snapshot.qt-project.org/4.8/stylesheet.html).
3. the only one standard push button behavior - show menu (see QPushButton::setMenu).