I have some trouble trying to set an icon for my QT application.
The icon is named "room.ico" and is on the same directory as the source file.
Here is the code :
#include <QApplication>
#include <QWidget>
int main( int argc, char *argv[ ] )
{
QApplication app( argc, argv) ;
QWidget fenetre;
fenetre.setWindowIcon(QIcon("room.ico")); // Nothing happens
fenetre.setWindowTitle("Heloo");
fenetre.show();
return app.exec() ;
}
I have tried to add win32:RC_ICONS += room.ico
in the .pro file
but that didn't work. I have also tried "./room.ico"
but still no icon.
I have tried to use this :
QPixmap pixmap = QPixmap ("room.ico");
fenetre.setWindowIcon(QIcon(pixmap));
And guess what !!! it didn't work ... i'm just a newbie to QT :p
Any suggestions will be appreciated , thanks
QT's documentation for QWindow::setWindowIcon
should be what you need.
setWindowIcon
and pass in a QIcon
:
app.setWindowIcon(QIcon(":/room.ico"));
(this assumes your file is in the resource file)Your problem appears to be that you didn't prepend :/
when passing in the filename to QIcon
.