3

I've been trying to set my application's icon following the directions here:

http://qt-project.org/doc/qt-5/appicon.html

If I understand correctly, the process should be fairly simple:

  1. Create an icon file (FlySightViewer.icns) using iconutil. I followed the directions here: https://stackoverflow.com/a/20703594/443822.

  2. Add ICON = FlySightViewer.icns to the .pro file.

However, when I follow these steps, the icon remains the default Qt application icon. I've tried deleting the app bundle and build folder, since I've read that these are sometimes not rebuilt through the usual process. This doesn't seem to resolve the issue.

Looking a bit deeper, when I run qmake from Qt Creator, the generated Makefile contains several instances of FlySightViewer.icns, including this line:

@$(COPY_FILE) ../flysight-viewer-qt/src/FlySightViewer.icns FlySightViewer.app/Contents/Resources/FlySightViewer.icns

The file ../flysight-viewer-qt/src/FlySightViewer.icns seems to be right where I expect it to be. However, when I build the project and look inside the app bundle, the icon is nowhere to be found. The only thing in the Resources folder is empty.lproj.

So it seems to me that the icon isn't appearing as expected because it is not being copied to the app bundle, but I have no idea why that might be.

Any help would be appreciated. I realize this is a fairly common question, but none of the answers I've found here seems to have helped.

Thanks for your time!

Community
  • 1
  • 1
Michael Cooper
  • 2,255
  • 2
  • 18
  • 21
  • The icns format can contain multiple versions of the image, at different sizes. If you open the file in Preview, you'll see the different available images. Check that the sizes are multiples of 2 (e.g. 32x32, 64x64 etc). – TheDarkKnight Aug 18 '14 at 08:07
  • The sizes look okay. I have 1024x1024, 512x512 twice, 256x256 twice, 128x128, 64x64, 32x32 twice, and 16x16. Some of these come from the "high resolution" versions with "@2x" suffix. – Michael Cooper Aug 18 '14 at 08:54
  • 512x512 twice and 32x32 twice; why two versions? – TheDarkKnight Aug 18 '14 at 09:02
  • I followed the instructions in the link above to create the icon file, which includes "high resolution" versions. You can see the same advice in this link direct from Apple: https://developer.apple.com/librarY/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Optimizing/Optimizing.html – Michael Cooper Aug 18 '14 at 15:20
  • Under which target do those COPY_FILE actions reside, and are you building that target? – Kuba hasn't forgotten Monica Aug 18 '14 at 15:42
  • @kuba: Good question. It looks to me like the target is simply ```:```, but I'm not sure what this means in a Makefile. – Michael Cooper Aug 18 '14 at 18:15

2 Answers2

2

Add this line into .pro file:

QMAKE_INFO_PLIST = Info.plist

Then create the .plist and set the icon name there. I won't paste an example .plist because it's quite large, but you can see how it's done by right-clicking a random app and selecting "show package contents".

SurvivalMachine
  • 7,946
  • 15
  • 57
  • 87
0

With older versions of Qt, I settled on changing the icon manually. However, the most recent version of Qt (or macdeployqt) seems to have fixed the problem, so I no longer need to set the icon manually.

Michael Cooper
  • 2,255
  • 2
  • 18
  • 21