PDA

View Full Version : Styling QPushbutton with a Popup QDockWidget



Phlucious
24th May 2012, 22:50
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?)

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?

AlekseyOk
25th May 2012, 13:41
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-snapshot.qt-project.org/4.8/stylesheet.html).
3. the only one standard push button behavior - show menu (see QPushButton::setMenu).