PDA

View Full Version : QToolButton - doesn't change icons when pressed



walsha3000
21st February 2010, 01:40
I can't seem to get the ToolButton icon to change when pressed.
This is the simple code I use...

btnArrowLeft = new QToolButton;
btnArrowLeft->setObjectName("ArrowLeft");
// make the icon
QIcon iconGif( "icons/iconBack1.gif");
iconGif.addFile( "icons/iconBack2.gif", iconSize, QIcon::Active, QIcon::Off );
//
btnArrowLeft->setIcon( iconGif );

Am I missing some obvious part?
Thanks for any help
andy walsh

Lykurg
21st February 2010, 11:03
It's because "QIcon::Off" is only displayed if the button is disabled. There is no such function out of the box in Qt.

For a solution see this recent thread: http://www.qtcentre.org/threads/28281-Qt-Picture-change. For you it is ":pressed" and mousePressEvent and mouseReleaseEvent.