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

sql - VB.NET Operand type clash: date is incompatible with int error -

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

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -