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.

  1. make icon file (you appear have done already: room.ico
  2. add icon file qt resource file (.qrc or .rc) should add project (the documentation discusses how this
  3. use setwindowicon , pass in qicon:
    1. app.setwindowicon(qicon(":/room.ico")); (this assumes file in resource file)

your problem appears didn't append :/ when passing in filename qicon.


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -