Setting icon on a Mac with Qt

旧时模样 提交于 2019-12-21 21:42:52

问题


As described in the Qt-Documentation I have created my icon file with the icon-composer. Then I have inserted in my .pro-file the following line.

ICON = 3D_Modell.icns

While compiling I get the following error:

No rule to make target `../3D', needed by `3D_Modell.app/Contents/Resources/3D_Modell.icns'

Where is the Contents/Resources folder? Where exactly do I put the icns-file. I have put it into the folder where my project and all cpp and h files lie.


回答1:


The instructions suggest you can add the icon manually:

  1. Create an Info.plist file for your application (using the PropertyListEditor, found in Developer/Applications).
  2. Associate your .icns record with the CFBundleIconFile record in the Info.plist file (again, using the PropertyListEditor).
  3. Copy the Info.plist file into your application bundle's Contents directory.
  4. Copy the .icns file into your application bundle's Contents/Resources directory.

To get access to your application bundle from the finder, right-click on your application and select 'show package contents' from the context menu. This will open a new finder window from which you can navigate to /Contents/Resources/.

Hope this helps.

EDIT:

The PropertyListEditor utility is in Developer/Applications/Utilities/. You can use it to "open" your application bundle, and edit the plist (located in the bundle's /Contents/ folder). The CFBundleIconFile item is helpfully called Icon File in the editor, but if you select View > Show Raw Keys/Values you can see the actual property names.




回答2:


All we have in our .pro file is:

macx:ICON = $${PWD}/my_app.icns

The icon is in the same directory as the .pro file. No manual steps are necessary.




回答3:


Sounds like an issue with the icon name. Try Modell.icns instead.



来源:https://stackoverflow.com/questions/9515726/setting-icon-on-a-mac-with-qt

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