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

Setting the Application Icon



  • Hi,
    im trying to set an icon for my application.

    I tought i will simply create an icon, put it in my resources (qrc) and add RC_ICONS = myappico.ico in my .pro,
    but the doc say :
    However, if you already have an .rc file, for example, with the name myapp.rc, which you want to reuse, the following two steps will be required. First, put a single line of text to the myapp.rc file:

    i have a resources.rc + version.h files for version handling purposes,

    //resources.rc looks like this, and i dont know where to add the line

    IDI_ICON1 ICON "myappico.ico"

    #include <windows.h>
    #include "version.h"
    
    VS_VERSION_INFO VERSIONINFO
    FILEVERSION     VER_FILEVERSION
    PRODUCTVERSION  VER_PRODUCTVERSION
    
    BEGIN
        BLOCK "StringFileInfo"
        BEGIN
            BLOCK "040904E4"
            BEGIN
                VALUE "CompanyName",        VER_COMPANYNAME_STR
                VALUE "FileDescription",    VER_FILEDESCRIPTION_STR
                VALUE "FileVersion",        VER_FILEVERSION_STR
                VALUE "InternalName",       VER_INTERNALNAME_STR
                VALUE "LegalCopyright",     VER_LEGALCOPYRIGHT_STR
                VALUE "LegalTrademarks1",   VER_LEGALTRADEMARKS1_STR
                VALUE "LegalTrademarks2",   VER_LEGALTRADEMARKS2_STR
                VALUE "OriginalFilename",   VER_ORIGINALFILENAME_STR
                VALUE "ProductName",        VER_PRODUCTNAME_STR
                VALUE "ProductVersion",     VER_PRODUCTVERSION_STR
            END
        END
    
        BLOCK "VarFileInfo"
        BEGIN
            VALUE "Translation", 0x409, 1252
        END
    END
    
    


  • Hi @LeLev,

    Did you try to put your line at start of your existing rc file, after the includes ?
    It is defined as this in the Qt example projects like Qt Win Extras - Quick Player example or Active Qt Wrapper example



  • This post is deleted!


  • Hi @LeLev,

    Did you try to put your line at start of your existing rc file, after the includes ?
    It is defined as this in the Qt example projects like Qt Win Extras - Quick Player example or Active Qt Wrapper example



  • @Gojir4 hi
    Thank you so much!
    I did it before but it was underlined by Qt Creator and there was an error on that line saying :

    Semantic Issue : error unknown type name IDI_ICON1

    so hadn't even tried to compile.
    But it actually works.
    Thank you


Log in to reply