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);
精彩评论