How to set the application icon in a Qt applicatio

2019-07-04 11:59发布

Following up on this answer to this question, I would like a clear, step-by-step set of instructions on how to set the application icon for a Qt application on OS X sufficient for distribution of the application via an installer and/or through the App Store.

The instructions should include how to set the four sizes of the icon, as referenced in the linked answer, above.

Please bear in mind that I have no experience in distributing OS X applications, building installers for OS X applications, or setting the icon that appears in the Finder bar for OS X applications. Rather, I am an experienced C++ programmer (mostly on Windows and Linux).

I especially seek a clear, step-by-step set of instructions.

标签: c++ macos qt icns
2条回答
老娘就宠你
2楼-- · 2019-07-04 12:18

First of all I'd like to mention that Icon Composer for XCode won't work here because it's not possible to create icns file with resolution 1024x1024 px.

To generate icns file I used iConvert Icons. The major drawback is that it's not free. To generate icns file all you need is png image with resolution 1024x1024 or more. The process is really simple so I won't cover it.

After that you'll have to include your icon in your project. To do that insert path to your icon in your Qt application's .pro file:

macx-clang {
    ICON = osx.icns
}
查看更多
欢心
3楼-- · 2019-07-04 12:31

You can automate icon creation by placing the following files in an icon.iconset directory:

icon_128x128.png
icon_128x128@2x.png
icon_16x16.png
icon_16x16@2x.png
icon_256x256.png
icon_256x256@2x.png
icon_32x32.png
icon_32x32@2x.png
icon_512x512.png
icon_512x512@2x.png

Then run the following command:

iconutil -c icns icon.iconset

It'll create the icons.icns that you'll reference with the ICON qmake variable.

查看更多
登录 后发表回答