PDA

View Full Version : Adding Image to QPushButton


Seema Rao
8th February 2006, 10:56
Hi all,

I am using Qt version 4.0.1. I am trying to add a Image on QPushButton
So here is the program I have written,

#include <QtGui>
#include <QPushButton>
int main( int argc, char **argv )
{
QApplication a( argc, argv );
QPushButton *button = new QPushButton ("Rock and Roll");
button->setPixmap(QPixmap(" Door.bmp"));
button->show();
return a.exec();
}


But it gives compilation "error no matching function for call to `QPushButton::setPixmap(QPixmap)'"
Can some body explain how to do it? Same lines are explained in Qt 4.01.
but I dont know why its not compiling?


Thanks in Advance,
Seema Rao

high_flyer
8th February 2006, 11:26
In Qt4 QPushButton has no setPixmap() method.
Use setIcon() instead.
Push buttons display a textual label, and optionally a small icon. These can be set using the constructors and changed later using setText() and setIcon(). If the button is disabled the appearance of the text and icon will be manipulated with respect to the GUI style to make the button look "disabled".