Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Application Icon not shown in Mac OS X Dock

    General and Desktop
    4
    7
    5320
    Loading More Posts
    • 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
      leonardyu last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • L
          leonardyu last edited by

          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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              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 Reply Quote 0
              • S
                ShekharIceman @SGaist last edited by

                @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 Reply Quote 0
                • M
                  mpergand last edited by

                  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 Reply Quote 0
                  • First post
                    Last post