Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Application Icon not shown in Mac OS X Dock



  • My applicaiton is developed with Qt 4.8 and we have set the application title and icon with the statements like
    setWindowTitle("AppTitle");
    setWindowIcon(QIcon(":/images/appicon.png"));
    The application icon is correctly shown in the title bar, but not in Dock. Instead a dark gray icon (overlaid with four chars "exec") is shown in Dock. So how can I make application icon shown in Dock? Thanks.


  • Lifetime Qt Champion

    Hi,

    The procedure is described "here":http://doc.qt.io/qt-5/appicon.html#setting-the-application-icon-on-os-x (it's also valid for Qt 4)



  • Thank you for your help SGaist.
    As I use CMake to manage the project files, I modify the CMakeLists.txt file accordingly. The added piece of CMakeLists.txt is:
    @
    IF (CMAKE_HOST_APPLE)
    SET(MACOSX_BUNDLE_EXECUTABLE_NAME myapp)
    SET(MACOSX_BUNDLE_ICON_FILE myapp.icns)
    SET(MACOSX_BUNDLE_BUNDLE_NAME MyAppTitle)
    ADD_EXECUTABLE(myapp MACOSX_BUNDLE ${SOURCES})
    ENDIF (CMAKE_HOST_APPLE)
    @

    Next I run CMake to regenerate project files (.xcodeproj) and build the project. After the build, the myapp.app folder is created under Debug folder as expected.
    Then I manually create Resources folder under Contents folder and copy myapp.icns into this folder.
    However, when I run the program, the icon shown in Dock is still a generic icon, not myapp.icns. This time it changes from the dark-gray-background-with-exec-chars to white-background-with-xcode-symbols (pen, ruler) icon.

    [edit: added missing coding tags @ SGaist]


  • Lifetime Qt Champion

    I've merged the two threads, the posting bug appears from time to time


  • Lifetime Qt Champion



  • @SGaist Tried the procedure mentioned in the link, when application is Run, my app.icns is copied in the Resources file of the myapp.app but it is not linked to the icon in the info file, tried manually but still it won't work.



  • Try the following:

    In your pro file:

    macx{
     QMAKE_INFO_PLIST   =	Mac/Info.plist
     ICON        =   Mac/AppIcon.icns
    }
    

    In my case, the info.plist and icon files are in a folder called 'Mac' inside my project folder.

    In the info.plist file, you must have:

    <key>CFBundleIconFile</key>
    <string>AppIcon</string>
    

Log in to reply