For one button, I can do this:

p1->setIcon(QIcon(":resource/1.png")); p1->setIconSize(QSize(48,48)); 

And how to make a slot that would do the same?

  • if you are about how to create slots, then youtu.be/IUrLxMv-HGA?t=971 for example, in the cpp file in the slot you write your code to replace the button. To open the slot creation menu, right-click on the button you need in interface design mode - Amir Afendin
  • I need a slot that does the same thing as I indicated in the question. - Tokiwartoot
  • Needed when replacing a button inside a slot, I already indicated the code for replacing a specific button in the question - Tokiwartoot
  • create a slot, then take your code and transfer it to the slot - Amir Afendin
  • Well, I also thought so, I just transfer the code specified in the question to the slot and that's it, but I have the p1 button in this code, at startup it swears that this button is not announced - Tokiwartoot

1 answer 1

Helped on another forum, did so:

  void myClass::mySlot() { QPushButton* btn = qobject_cast<QPushButton*>(sender()); if ( btn == p1) { p1->setIcon(QIcon(":resource/1.png")); p1->setIconSize(QSize(48,48)); } ..... }