c++ - How to set an application icon in Qt -
i have trouble trying set icon qt application.
the icon named "room.ico" , on same directory source file.
here 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 add win32:rc_icons += room.ico
in .pro file
didn't work. have tried "./room.ico"
still no icon.
i have tried use :
qpixmap pixmap = qpixmap ("room.ico"); fenetre.setwindowicon(qicon(pixmap));
and guess !!! didn't work ... i'm newbie qt :p
any suggestions appreciated , thanks
qt's documentation qwindow::setwindowicon
should need.
- make icon file (you appear have done already: room.ico
- add icon file qt resource file (.qrc or .rc) should add project (the documentation discusses how this
- use
setwindowicon
, pass inqicon
:app.setwindowicon(qicon(":/room.ico"));
(this assumes file in resource file)
your problem appears didn't append :/
when passing in filename qicon
.
Comments
Post a Comment