Packaging Qt apps for Mac OS X

From MyLabWiki
Jump to: navigation, search

Once you got tired of reading and trying to comprehend Deploying an Application on Mac OS X in the Qt documentation, you realize at the bottom of the page that all you have to do is:

  1. Build your application in release mode
  2. Execute "macdeployqt"
    • see -h for options
    • good to use -verbose=2

This will bundle all the Qt libraries into the - this will be approximately 40 MB. I guess one could still do the manual process for small applications that do not need all the Qt libraries. Or maybe the unnecessary libraries can be removed again manually?


To create a .dmg we can either use the -dmg option to macdeployqt or use the Mac Disk Utility as described here or here (without the encryption part). In the most basic form:

  1. Move and all other files into a directory
  2. Start Disk Utility
  3. Select File → New → Disk Image from Folder
    • Image Format: compressed
    • Encryption: none
    • Other choices may work as well.

Application and package icon

Need update, but can still use Icon Composer 2x

  1. Create an icon with size 1024x1024 pixels
  2. Drag and drop it into Icon Composer
    • Start with the largest one, then drag it to smaller ones.
  3. Save .icns file
    • Note: Icon Composer can also create .ico file but these use different sizes
  4. Edit and add: ICON = path/to/icons.icns[1]
    • Can be wrapped in a macx { ... } contditional,[2] see e.g. qthid-2.2
  5. Ejoy the results:

Note: We can also copy and paste .icns files in/out of the bundle and edit the .plist file.

During runtime the dock icon can be changed by calling QWidget::setWindowIcon() on the main window[3].

Including additional data



  1. Setting the Application Icon
  2. Qt Forum: application icon
  3. Qt is Mac OS X Native

Bundle Programming Guide

Related article: Building GNU Radio on Mac OS X.