Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt5 Set application icon for Mac

Tags:

macos

icons

qt

qt5

I want to set the application's icon that should be seen on the Dock of a Mac. To do so, I added to the .pro file the following line:

ICON = $$_PRO_FILE_PWD_/Icons/Icon144x144.icns

(I also tried ICON = Icons/Icon144x144.icns)

If I understood Qt's documentation right, that should be enough but since my icon still can not be seen, I also added the following line to the mainwindow.cpp

setWindowIcon(QIcon("Icons/Icon144x144.icns"));

(I also tried with QIcon("Icon144x144.icns") and QIcon("/Users/MYNAME/PROJECT/Icons/Icon144x144.icns")).

I know that there are two similar questions about this issue: QT/C++ on MAC - Application Icon doesn't set and Setting icon on a Mac with Qt but since I'm still not able to see the right icon, I'm thinking if there is something different in the way that Qt5 allows setting the app icon from previous versions. Any clue?

EDIT:

I just saw that qmake is not adding the icon to the Resources folder inside the app...

like image 261
AlvaroSantisteban Avatar asked Nov 21 '12 17:11

AlvaroSantisteban


2 Answers

For what is worth, I have done exactly the same stuff as you with QT5 and it works.

Basically in my .pro file I have:

ICON = icon.icns

Moreover, I had to specify icon location in my app.plist file. Basically you have to set the CFBundleIconFile key to name of your icon. Hope it helps!

like image 78
Aki Avatar answered Oct 13 '22 18:10

Aki


First of all check if the path is right (especially if you're doing a shadow build), more often than not qmake can't find the proper icon file.

However I was stumbling on a similar issue:

What has been happening to me was that the app bundle was not being updated (resource-wise) so you have to delete the yourprogram.app directory and let qmake re-create it, this way the icon is updated correctly.

like image 36
Alienpenguin Avatar answered Oct 13 '22 19:10

Alienpenguin