PDA

View Full Version : QPushButton Icon Image



QbelcorT
13th March 2009, 14:42
Hello Again..
I have a QPushButton, and I have an icon image on it. I am trying to change the image when the button is release.
Pressed = Image 1
Released = Image 2 = normal state
I have tried many combinations of QIcon On/Off Active/Disabled, but I cannot seem to get it working. The button is not a toggle, just a push and release button.
Thanks

JimDaniel
13th March 2009, 15:15
Take a look at QWidget::mouseReleaseEvent() and QWidget::mousePressEvent(). You can subclass QPushButton and re-implement those methods to change the icon to the appropriate one.

spirit
13th March 2009, 15:19
Take a look at QWidget::mouseReleaseEvent() and QWidget::mousePressEvent(). You can subclass QPushButton and re-implement those methods to change the icon to the appropriate one.

or install event filter and catch QMouseEvent. ;)

QbelcorT
13th March 2009, 15:26
thanks for your quick response guys.
I thought there might be a way with the QIcon states, I think it's just as easy to use the Pressed() and Released() slot. I've tried that and it works.