Reputation: 3932
Can 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.
Upvotes: 2
Views: 6119
Reputation: 184
Just as a more flexible way of doing it:
myPushButton->setIcon(QIcon);
Upvotes: 1
Reputation: 9634
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.
Upvotes: 2