Change button Icon on toggle
Hello, all;
I'm trying to program a QPushButton or QToolButton to change the icon being displayed when toggled/activated. Unfortunately, I'm on a shard system and unable to use QSetIcon or add it to the library. Any suggestions on how to proceed?
Thanks in advance,
Allan
Re: Change button Icon on toggle
Probably you want to use QIcon class . You can find example how to use it with QPushButton in Assistant.
If you want to toggle the icon, you should connect signal clicked() or toggled() of your button to your custom slot and in that slot just call QPushButton::setIcon() method.
Again, read about QPushButton and QIcon in Assistant.
If your button is checkable you can also do it without signal and slot. Here's an example:
Code:
b->setIcon(*ico);
b->setCheckable(true);
Quote:
Unfortunately, I'm on a shard system and unable to use QSetIcon or add it to the library
I really don't understand what do you mean. Could you elaborate?
Re: Change button Icon on toggle
Quote:
Originally Posted by
calhal
I really don't understand what do you mean. Could you elaborate?
Sorry, that was supposed to read "I'm on a shared system". (Fat Fingers strikes again...) Basically, the documentation for QSetIcon mentions the need for the "qseticon.h" header file, which I can't add to the library because I'm not the Administrator and don't have access. In any event, I will try the method you posted above, many thanks!
Re: Change button Icon on toggle
Success! Thank you very much, calhal.