tags:

views:

113

answers:

2

hi,

Can anyone help me on putting an image or icon over a push button. I tried with style sheet but not working. Please help

+1  A: 

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.

Shadow
Thanks for ur sudden reply..Her ei am getting error..QIcon identifier not found and setsetgeometry not a member of QPushButton..... I included QIcon in header
@sijith *setgeometry* not a member, but *setGeometry* is! Plz, read docs first.
mosg
Thanks... Its working but Qicon error is there
Qicon not QIcon it is..i have updated code above, see
Shadow
Thanks... Rocking forum....
A: 

Just as a more flexible way of doing it:

myPushButton->setIcon(QIcon);
Silent Penguin