Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set application icon in a Qt-based project?

Tags:

c++

qt

How do you set application icon for application made using Qt? Is there some easy way? It's a qmake-based project.

like image 951
Pavels Avatar asked Sep 22 '09 14:09

Pavels


People also ask

How set Qt application icon?

Setting the Application Icon on Windows This can be done using Microsoft Visual Studio: Select File >> New, and choose the Icon File. Note: You need not load the application into the Visual Studio IDE as you are using the icon editor only.

How does Qt application work?

Qt uses a command line tool that parses these project files in order to generate "makefiles", files that are used by compilers to build an application. This tool is called qmake. But, we shouldn't bother too much about qmake, since Qt Creator will do the job for us. TEMPLATE describes the type to build.


1 Answers

For Qt 5, this process is automated by qmake. Just add the following to the project file:

win32:RC_ICONS += your_icon.ico 

The automated resource file generation also uses the values of the following qmake variables: VERSION, QMAKE_TARGET_COMPANY, QMAKE_TARGET_DESCRIPTION, QMAKE_TARGET_COPYRIGHT, QMAKE_TARGET_PRODUCT, RC_LANG, RC_CODEPAGE.

For Qt 4, you need to do it manually. On Windows, you need to create a .rc file and add it to your project (.pro). The RC file should look like this:

IDI_ICON1 ICON DISCARDABLE "path_to_you_icon.ico" 

The .pro entry should also be win32 specific, e.g.:

win32:RC_FILE += MyApplication.rc 
like image 156
Rob Avatar answered Sep 30 '22 08:09

Rob