PDA

View Full Version : QPushButton with image on it



msmihai
6th January 2009, 20:13
I tried to do a simple thing .Using the QT Designer, i put an image ( png format ) on a QPushButton . When i test the form in the Qt Designer , it shows that picture just fine.
But when i write an application using that design ( the ui file ) , the buttons doesn't have the picture on it .

I checked the ui_gui.h file generated by qt and i found this code



QIcon icon;
icon.addPixmap(QPixmap(QString::fromUtf8("Button-Reload-48x48.png")), QIcon::Normal, QIcon::Off);
Button1->setIcon(icon);


So ... it shoud have been there... any ideas ? the picture is 48x48.

wysota
6th January 2009, 20:53
You are using a relative file path and then later when you run the application outside the original directory, the file is not there. Either use an absolute path or embed the image as a Qt resource into the application binary.