Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Application Icon not shown in Mac OS X Dock

Application Icon not shown in Mac OS X Dock

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 6.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    leonardyu
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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)

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      0
      • L Offline
        L Offline
        leonardyu
        wrote on last edited by
        #3

        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]

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            This "thread":http://stackoverflow.com/questions/22745728/cmake-set-icon-for-a-mac-osx-app might help

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • SGaistS SGaist

              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)

              S Offline
              S Offline
              ShekharIceman
              wrote on last edited by
              #6

              @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.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mpergand
                wrote on last edited by
                #7

                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>
                
                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved