Difference between revisions of "Packaging Qt apps for Mac OS X"

From MyLabWiki
Jump to: navigation, search
(Application and package icon)
(Application and package icon)
Line 19: Line 19:
 
# Save .icns file
 
# Save .icns file
 
#* Note: Icon Composer can also create .ico file but these use different sizes
 
#* Note: Icon Composer can also create .ico file but these use different sizes
# Put the .icns file in myprog.app/Contents/Resources
+
# Edit project.pro and add: ICON = path/to/icons.icns<ref>[http://doc.qt.nokia.com/4.7-snapshot/appicon.html Setting the Application Icon]</ref>
# Edit myprog.app/Contents/Info.plist
+
#* Can be wrapped in a macx { ... } contditional,<ref>[http://www.qtforum.org/article/32922/application-icon.html Qt Forum: application icon]</ref> see e.g. [http://github.com/csete/qthid qthid-2.2]
  <dict>
+
# Ejoy the results:
      <key>CFBundleIconFile</key>
+
#* http://twitpic.com/42d86d
      <string>myicons.icns</string>
+
#* http://twitpic.com/431ilo
      ...
+
 
+
See the result: http://twitpic.com/42d86d
+
 
+
Ok, this didn't work even though it is the same procedure as described here: http://doc.qt.nokia.com/4.7-snapshot/appicon.html &rarr; try again, and also look at http://www.qtforum.org/article/32922/application-icon.html
+
 
+
Strangely enough, I could paste .icns files from other applications onto qthid so maybe it was my .icns file? Try the procedure with other icns files.
+
  
 +
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 [http://doc.qt.nokia.com/4.7/qwidget.html#windowIcon-prop QWidget::setWindowIcon()] on the main window<ref>[http://doc.qt.nokia.com/4.7/qtmac-as-native.html Qt is Mac OS X Native]</ref>.
 
During runtime the dock icon can be changed by calling [http://doc.qt.nokia.com/4.7/qwidget.html#windowIcon-prop QWidget::setWindowIcon()] on the main window<ref>[http://doc.qt.nokia.com/4.7/qtmac-as-native.html Qt is Mac OS X Native]</ref>.

Revision as of 11:34, 26 February 2011

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 myprog.app" (see -h for options)

This will bundle all the Qt libraries into the myprog.app - 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?

Note: http://doc.qt.nokia.com/4.7/mac-differences.html#bundle-based-libraries

To create a .dmg we can either use the -dmg option to macdeployqt or use the Mac Disk Utility as describe here or here (without the encryption part).


Application and package icon

  1. Create icons with size: 16x16, 32x32, 128x128, 256x256 and 512x512
  2. Paste them into Icon Composer
  3. Save .icns file
    • Note: Icon Composer can also create .ico file but these use different sizes
  4. Edit project.pro 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 addition data

How?

References

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

Bundle Programming Guide