Sijith
Sijith

Reputation: 3932

How to put an image or icon over a pushButton

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

Answers (2)

Silent Penguin
Silent Penguin

Reputation: 184

Just as a more flexible way of doing it:

myPushButton->setIcon(QIcon);

Upvotes: 1

Naruto
Naruto

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

Related Questions