PDA

View Full Version : Change QIcon



Diph
30th July 2009, 12:27
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.

caduel
30th July 2009, 16:26
this is a but in your code. are you sure your btn variable does get initialized properly?

Diph
2nd August 2009, 07:29
this is a but in your code. are you sure your btn variable does get initialized properly?
You were right. :D

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