Setting icon on a Mac with Qt

2020-07-24 05:54发布

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.

标签: c++ qt icons
3条回答
放荡不羁爱自由
2楼-- · 2020-07-24 06:37

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楼-- · 2020-07-24 06:46

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

查看更多
不美不萌又怎样
4楼-- · 2020-07-24 06:54

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.

enter image description here

查看更多
登录 后发表回答