开发者

How to put an image or icon over a pushButton

开发者 https://www.devze.com 2022-12-30 17:18 出处:网络
C开发者_StackOverflowan anyone help me with putting an image or icon on a push button? I tried with a style sheet but that\'s not working. Please help.Qpushbutton constructor says.

C开发者_StackOverflowan anyone help me with putting an image or icon on a push button? I tried with a style sheet but that's not working. Please help.


Qpushbutton constructor says. QPushButton ( const QIcon & icon, const QString & text, QWidget * parent = 0 );

QPushButton *pushme = new QPushButton (QIcon(":/new/prefix1/Sunset.jpg"),"Test");
pushme->setGeometry(20,20,50,40);
pushme->show();

give the specific width and height of icon, based on your convince in setgeometry.


Just as a more flexible way of doing it:

myPushButton->setIcon(QIcon);
0

精彩评论

暂无评论...
验证码 换一张
取 消