Results 1 to 3 of 3

Thread: Change QIcon

  1. #1
    Join Date
    Jun 2008
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Change QIcon

    How do I change button's icon in function? I can set the icon in constructor by calling btn->setIcon(QIcon("ico1.png")) but if I try to change icon in function (btn->setIcon(QIcon("ico2.png"))) the program crashes. I don't want to change the icon on toggle.

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Change QIcon

    this is a but in your code. are you sure your btn variable does get initialized properly?

  3. The following user says thank you to caduel for this useful post:

    Diph (2nd August 2009)

  4. #3
    Join Date
    Jun 2008
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Change QIcon

    Quote Originally Posted by caduel View Post
    this is a but in your code. are you sure your btn variable does get initialized properly?
    You were right.

    The initialization was done to local variable which had the same name.

Similar Threads

  1. Change database data in the QTabelView
    By sophister in forum Qt Programming
    Replies: 3
    Last Post: 9th April 2009, 16:40
  2. Change cursor & status during Drag & Drop
    By ronlongo in forum Qt Programming
    Replies: 0
    Last Post: 1st December 2008, 16:56
  3. Make error with Qt Jambi 4.3.2_01
    By pamalite in forum Installation and Deployment
    Replies: 0
    Last Post: 22nd November 2007, 12:05
  4. statusBar() message color change
    By mclark in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 23:20
  5. Can't change the text display of a QTreeview item.
    By johnny_sparx in forum Qt Programming
    Replies: 3
    Last Post: 2nd June 2006, 01:03

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.