Results 1 to 2 of 2

Thread: QToolButton - doesn't change icons when pressed

  1. #1
    Join Date
    Feb 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default QToolButton - doesn't change icons when pressed

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QToolButton - doesn't change icons when pressed

    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.

Similar Threads

  1. QTableView key pressed
    By radu_d in forum Qt Programming
    Replies: 6
    Last Post: 1st August 2013, 03:20
  2. Catch pressed keys
    By jano_alex_es in forum Newbie
    Replies: 5
    Last Post: 30th July 2009, 12:32
  3. Can't See QToolButton pressed Signal from QTableWidget
    By mbrusati in forum Qt Programming
    Replies: 0
    Last Post: 23rd September 2008, 20:06
  4. Getting the row for button pressed
    By steg90 in forum Qt Programming
    Replies: 2
    Last Post: 28th November 2007, 15:45
  5. Change icons on static QMessageBox
    By manucorrales in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2006, 19:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.