简体   繁体   English

我们如何从QPushButton中删除图标?

[英]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? 我该怎么做?

In order to delete an image you can set an empty image instead of existing one. 要删除图像,您可以设置空图像而不是现有图像。 For example: 例如:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM