Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QTCreator Application Icon



  • Hello,
    i try to set application icon but it doesn't work.

    What i did :

    -I have create ressource.rc file and add :

    @
    IDI_ICON1 ICON DISCARDABLE "gear.ico"
    @

    -I have push gear.ico in the .pro folder :
    "Img":http://www.hostingpics.net/viewer.php?id=813808bugQT.png

    -And my .pro file :
    "Img":http://www.hostingpics.net/viewer.php?id=970014bugQT2.png

    What is the problem ? My application icon don't change.
    Thanks advanced for the help.
    Bye.

    [EDIT: code formatting, Volker]



  • add line to end of your .pro file:
    @win32:RC_FILE = ressource.rc@



  • Nothing has changed.



  • For what it's worth, I have in my .rc file:

    @
    DI_ICON1 ICON DISCARDABLE "application.ico"
    @

    Note, that it's DI_ICON1, not IDI_ICON1 (the first I is superfluous).



  • I'm creating a secondary window and showing it using showFullScreen, and it's ALT-TAB icon is the generic app icon. Using IDI_ICON1 instead of DI_* fixes that, and appears to work everywhere else as well. I'm actually using both, since I'm trying to maintain functionality across Windows platforms from XP to 8.



  • You can set an app for Qt application in code. No .rc files needed, and all further windows will automatically inherit this icon.

    My solution:

    @// in main.cpp
    QApplication a(argc, argv);

    #ifndef APPLE
    a.setWindowIcon(QIcon(":icon.ico"));
    #endif
    @

    On OS X program crashes on a.setWindowIcon line ( that's why preprocessor directives). As I know, you need to use apple ico format, but i didn't test it in theory ( I worked on friends macbook back then ).



  • Yeah, I think Jake is Right... Try By using and write us whether it works or not.

    @a.setWindowIcon(QIcon("fileName.ico"));@


Log in to reply