Make a native Mac App Bundle of Qt Designer with Qt Jambi
Qt Designer is an important tool for designing and building graphical user interface from Qt components. However, if you are a Java programmer and want to use Qt Designer with Qt Jambi in Mac, you can’t simply double-click the Designer app bundle shipped with Qt Jambi SDK. If you do so, you can still invoke the Designer, but… with the C++ environments, it’s useless for Java programmers. Instead, if you want to use Qt Designer with Qt Jambi. You have to start the program from a `designer.sh` script placed in your Qt directory. It’s pretty annoying because you’ll need a Terminal to run this script until you turn it off. Also, it’s not intuitive.
So, I checked the script code and found what it does is simply to set some environment variables and then execute the Designer binary within the Designer app bundle. Therefore, I decided to make a “real” app bundle for the Qt Designer with Qt Jambi. It’s pretty easy to do this job by using Jump, one of my open source projects. Here’s the instructions.
- Go to the `QTDIR/bin` directory in Finder.
- Right-click the `Designer` app bundle, select `Show Package Contents`, and it will open a new Finder window.
- In the new opened Finder window, go to the `Contents/MacOS` directory, then copy the `Designer` binary back to `QTDIR/bin`.
- Now pick a location to start writing our wrapper. I simply make a directory called `designer` in my home directory, then open a Terminal and switch to it.
- Back to the new opened Finder window, copy the `Contents/Resources/designer.icns` file to our new created `designer` directory.
- Create a Python module named `designer.py` in `designer` directory, and its content looks like this:
import os # Replace this path to your QTDIR qt_home = '/Users/olliwang/workspace/qtjambi-mac-lgpl-4.5.2_01' def main(): os.environ['QTDIR'] = qt_home os.environ['DYLD_LIBRARY_PATH'] = os.path.join(qt_home, 'lib') os.environ['QT_PLUGIN_PATH'] = os.path.join(qt_home, 'plugins') os.environ['PATH'] = os.path.join(qt_home, 'bin') classpaths = [] for filename in os.listdir(qt_home): if filename.endswith('.jar'): classpath = os.path.join(qt_home, filename) classpaths.append(classpath) os.environ['CLASSPATH'] = ':'.join(classpaths) os.system(os.path.join(qt_home, 'bin/Designer')) - Create a `config.jp` file with following content:
dist_name = Designer main_entry_point = designer:main icns = designer.icns
- Run `jump app` in your Terminal, and you’ll see a new created directory called `dist`, our new app bundle is in there.
- Copy the created app bundle back to the `QTDIR/bin` directory, now double-click the `Designer` app bundle and everything should work fine. Cheers!
I use Python to write this wrapper for easy, you can of course do the same thing in Java. Just remember to modify the `main_entry_point` to the `Main Class` in config file.
Filed under: Jython, Programming, Python, Qt | Leave a Comment
Tags: App Bundle, bundle, Jump, Jython, Mac, Mac OS X, native, Programming, Python, Qt, Qt Designer, Qt Jambi, tutorial, wrapper




No Responses Yet to “Make a native Mac App Bundle of Qt Designer with Qt Jambi”