СhiliРepper
СhiliРepper

Reputation: 125

How can we delete icon from QPushButton?

After begining the program I set icons on all pushbuttons. Code is like this:

QImage img;
img.load(pictureName);    
ui->pushButton_1->setIcon(QPixmap::fromImage(img));
ui->pushButton_1->setIconSize(img.size());

But after some actions I need delete pictures and set some text. How can I do it?

Upvotes: 9

Views: 8722

Answers (1)

vahancho
vahancho

Reputation: 21250

In order to delete an image you can set an empty image instead of existing one. For example:

ui->pushButton_1->setIcon(QIcon());

Upvotes: 19

Related Questions