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. How to set Qt Application EXE Icon in MAC OS ?

How to set Qt Application EXE Icon in MAC OS ?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 4 Posters 13.8k 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.
  • Z Offline
    Z Offline
    Zain
    wrote on last edited by
    #1

    Hello All,

    I have developed Qt Application in MAC OS.I need to set Application EXE file icon.
    Here EXE means (.app) of MAC OS.

    I gone through with this link : http://doc.qt.digia.com/qt/appicon.html

    Using above link i have done setting my Qt Application setup and .exe Icon in Windows version.
    But steps given in above link for MAC OS not working.

    Please suggest me where I am going wrong.

    Thanks

    Zain

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      How are we supposed to know what you are doing wrong? You need to tell us what you have actually done. There are, for example 3 different sets of things to do in the OS X instructions you link. You need to do 2 of them.

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        Zain
        wrote on last edited by
        #3

        I have followed Instruction of Setting the Application Icon on Mac OS X .

        First I have created myicon.icns and included "ICON = myicon.icns" to my application .pro file.But nothing happened.

        Second I also done the following manually:

        i. Create an Info.plist file .
        ii. Associated my .icns record with the CFBundleIconFile record in the Info.plist file.
        iii. Copy the .icns file into my application bundle's Contents/Resources directory.

        But again nothing changes.My application .app file building with default MAC OS app files Icon.

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hardcodes.de
          wrote on last edited by
          #4

          Have you tried to "clean" and then delete the APP bundle in the build directory? Eventually the info.plist is not updated and/or Finder is lazy on showing new icons for existing files.

          while(!sleep){++sheep;}

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            Zain
            wrote on last edited by
            #5

            to hardcodes.de:

            Yes I have cleaned and deleted whole build directory files many time and buildup again.

            I am building in release mode.Is it OK?

            There is following code writing in my .pro file.
            @
            ICON = NetNewsWire256.icns

            QMAKE_INFO_PLIST = Info.plist
            OTHER_FILES += Info.plist
            @
            And Info.plist code is:
            @
            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
            <plist version="1.0">
            <dict>

            <array>
            <dict>

            <key>CFBundleTypeIconFile</key>
            <string>NetNewsWire256.icn</string>

                        </dict>
                </array>
            

            </dict>
            </plist>
            @

            Here is command using to packing my .app file

            acdeployqt myapplication.app

            and than creating .dmg using following command

            hdiutil create -format UDBZ -quiet -srcfolder myapplication.app myapplication.dmg

            1 Reply Last reply
            0
            • J Offline
              J Offline
              jjsd858
              wrote on last edited by
              #6

              Using the qt 5.0.1 download this works for me. My .icns file is in a project subdirectory "icons". I think when I tried 5.0.0 it wasn't working.

              .pro file statement....

              ICON = $$PRO_FILE_PWD/icons/icon128.icns

              1 Reply Last reply
              0
              • H Offline
                H Offline
                hardcodes.de
                wrote on last edited by
                #7

                I use
                @ICON = $$PWD/ICONNAME.icns@

                Where $$PWD is a reference to the file currently parsed = the .PRO file.
                The info.plist file is not referenced at all in my .PRO file. But there is
                @TEMPLATE = app@
                which should be there anyway IMHO.

                Are you sure that the s is missing in the info.plist file (NetNewsWire256.icn instead of NetNewsWire256.icns)?
                Is the icon file copied to the bundle (Resources directory inside the bundle)?
                When you ask if 'release' is ok, have you tried 'debug'? What's the result there?

                while(!sleep){++sheep;}

                1 Reply Last reply
                0
                • Z Offline
                  Z Offline
                  Zain
                  wrote on last edited by
                  #8

                  hardcodes.de:

                  I have tried with ICON = $$PWD/ICONNAME.icns but same result no icon.Also same in debug mode.

                  yes in Info.plist its NetNewsWire256.icns.

                  I am not getting why qmake is not creating default Info.plist as I written in this link http://doc.qt.digia.com/qt/appicon.html that if we are running qmake then only need to write only
                  "ICON = NetNewsWire256.icns" in our .pro file and automatically
                  Info.plist should be created in content directory and icon also automatically copied in content/Resource directory of app file.

                  My Qt version is 4.8.1 . Is it make any difference?

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    hardcodes.de
                    wrote on last edited by
                    #9

                    Sorry, running out of ideas.

                    while(!sleep){++sheep;}

                    1 Reply Last reply
                    0
                    • H Offline
                      H Offline
                      hardcodes.de
                      wrote on last edited by
                      #10

                      Now I have the same problem, it is caused by a "bug":https://bugreports.qt-project.org/browse/QTBUG-21267.

                      Now I also use a custom info.plist file and do some of steps on my own:

                      @# copy our info.plist template and replace variables, see qmake Variable Reference
                      QMAKE_INFO_PLIST = $$PWD/osx/info.plist

                      see https://bugreports.qt-project.org/browse/QTBUG-21267

                      QMAKE_INFO_PLIST_OUT = $${TARGET}.app/Contents/Info.plist
                      PRE_TARGETDEPS += $${TARGET}.app/Contents/Info.plist
                      HC_ICONNAME = name_of_a_beautiful_icon.icns

                      does not work, so maybe redundant

                      ICON = $$PWD/Icons/$${HC_ICONNAME}

                      write some extra info in the info.plist

                      QMAKE_POST_LINK += /usr/libexec/PlistBuddy -c "Set :GIT_COMMIT_HASH $${HC_GITHASH}" $${OUT_PWD}/$${TARGET}.app/Contents/Info.plist

                      SHORT_VERSION is replaced by the first 2 digits of the version number only. No TEMPLATE for full version available

                      QMAKE_POST_LINK += ;/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $${VERSION}" $${OUT_PWD}/$${TARGET}.app/Contents/Info.plist

                      if QMAKE_INFO_PLIST is assigned, the icon is not copied

                      QMAKE_POST_LINK += ;cp -n $$PWD/Icons/$${HC_ICONNAME} $${OUT_PWD}/$${TARGET}.app/Contents/Resources/.@

                      The QMAKE_POST_LINK looks a bit messy but additional build steps (that is the place where I believe it should be put) have no access to .PRO file variables. I'm going to replace that part with a single external bash script soon.

                      while(!sleep){++sheep;}

                      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