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...
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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With