Reputation: 79930
What are the steps to add Qt application icon on windows that shows on exe file in explorer?
Currently my icons show on app GUI windows but not on the exe file itself in the explorer.
The answer to How to set application icon in a Qt-based project? shows how to do it via qmake, by adding RC_ICONS
I don't use qmake. I don't use VS
, I use VS
compiler and any tools directly, in standard C++ app with Qt.
Is it possible to find steps to do it manually? Qt refers to winres.exe
but is there a way to use Qt tools directly, or any tools that comes with VS
?
I add icons manually by compiling them in, I design GUI in Qt Designer then compile via simple batch file on Windows 10. The dtresources.qrc
is created in Qt Designer. GUI window icons are then selected from resources file.
Example:
%qtdir%\bin\rcc -name icons dtresources.qrc -o detail/dtresources.cpp
set src=detail/dtresources.cpp *.cpp
cl /EHsc /MDd /Zi /nologo /Fa"x64/debug/" /Fd"x64/debug/vc120.pdb" /Fo"x64/debug/" /Fp"x64/debug
/%appname%.pch" /I"%qtdir%/include" /I"%qtdir%/include/QtCore" /I"%qtdir%/include/QtGui"
/I"%qtdir%/include/QtWidgets" "%qtdir%/lib/Qt5Guid.lib" "%qtdir%/lib/Qt5Widgetsd.lib"
"%qtdir%/lib/Qt5Cored.lib" %src% /link /out:"x64/debug/%appname%.exe"
example .qrc:
<RCC>
<qresource prefix="res">
<file>res/app.ico</file>
</qresource>
</RCC>
Upvotes: 1
Views: 924
Reputation: 2576
Yes, you can. Instead of windres.exe
, the Windows SDK provides rc.exe
, a.k.a. the Resource Compiler. You need first an image in .ico format (named here "app.ico") and a text file named "app.rc" with this content:
IDI_ICON1 ICON DISCARDABLE "app.ico"
You can compile this file with this command:
rc app.rc
That command will produce a file with the name "app.res". This RES file can be processed by the linker directly, or you may convert it to .obj with this command:
cvtres /MACHINE:X64 app.res
That command produces a file with the name "app.obj" (for architecture x86_64, use cvtres /h
to see other parameters). You need to give this .obj file to the linker when producing the executable. "cvtres.exe" comes from the VC compiler bin directory, and not the Windows SDK.
Upvotes: 4