开发者

How to put an image or icon over a pushButton

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜