Actually here is a quote from the documentation:

First, put a single line of text to myapp.rc file:

IDI_ICON1 ICON DISCARDABLE "myappico.ico"

maybe I misunderstand the expression single line , but the .rc file containing this single line gives an error

 Start tag exepted 

Placing the same expression between the lines

  <!DOCTYPE RCC> <RCC version="1.0"> IDI_ICON1 ICON DISCARDABLE "icon.ico" </RCC> 

Also gives an error:

 Unexpected text 

So where should I insert this line to change the icon?

UPD: my working resource file is:

 <!DOCTYPE RCC> <RCC version="1.0"> <qresource prefix="/"> ... <file>qml/main.qml</file> ... </qresource> </RCC> 

And attempts to insert a string into it also failed with the same errors.

UPD: And this is how I add rc to the project:

 set(RESOURCES resources/resources.qrc resources/proj.rc ) qt5_add_resources (QRC_SOURCES ${RESOURCES}) ... add_executable( proj_name ... ${QRC_SOURCES} ...) 

and just tried a new projname.rc there to add.

  • What version of the studio? Those RC files that I have do not use the XML format. - Vladimir Martyanov
  • Studio 15, the documentation on which I am trying to do is qt (and I actually have qt-qml application). I already have a resource file, it works well, but it has the format as in my second example. With tags <>. - Mira
  • Enter the version of the studio in question. The easiest option is to modify the existing RC file you have to try. - Vladimir Martyanov
  • @ Vladimir Martiyanov I have already tried to insert this line into my file, it produces exactly the same error - an unexpected text and the absence of a start tag. I created a separate file to exactly match the documentation. I don’t think that the studio matters here, as I collect the qt app. - Mira

2 answers 2

This rc file should be enough for the application icon:

 0 ICON "myappico.ico" 

Suppose your rc file is named resources.rc, then the cmake code will look like this:

 set(RESOURCES resources/resources.qrc ) qt5_add_resources (QRC_SOURCES ${RESOURCES}) ... add_executable( proj_name ... ${QRC_SOURCES} resources.rc ...) 

resources.rc is a windows-specific file, so you need to transfer it directly from source to add_executable , you don’t need it and you don’t need to do any preprocessing.

  • The same mistake - Start tag exepted - Mira
  • @Mira, show me how you feed the rc file to the compiler - ixSci
  • added a question - Mira
  • @Mira, this is a qrc file, and where is the rc file? - ixSci
  • one
    @Mira, yes, for Qt subsystem you need qico.dll, I just thought at first that you have an icon for the binary, and the application doesn’t have it in the taskbar. For a binary, this dll is not needed, but for use in the qt application, from qrc resources, ixSci is needed

I will add the answer @ixSci

For qmake, you need to add a file to the pro:

 RC_FILE = app.rc OTHER_FILES += app.rc 

App.rc example