How to set the application icon in a Qt application on OS X, sufficient for distribution?

风流意气都作罢 提交于 2019-12-12 15:23:26

问题


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.


回答1:


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
}



回答2:


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.



来源:https://stackoverflow.com/questions/21027988/how-to-set-the-application-icon-in-a-qt-application-on-os-x-sufficient-for-dist

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!