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

前端 未结 4 1413
无人及你
无人及你 2020-12-04 19:01

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

4条回答
  •  情书的邮戳
    2020-12-04 19:43

    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
    

提交回复
热议问题