| Sign In/My Account | View Cart |
| Article: |
Graphical Toolkits for OS X: wxPython | |
| Subject: | Request: Mixing Qt and Cocoa? | |
| Date: | 2007-05-16 06:44:17 | |
| From: | GeoffHutchison | |
|
Thanks for the tutorial on wxWidgets -- I've been curious about them for a while. I think this will be a great series.
|
||
Showing messages 1 through 2 of 2.
Request: Mixing Qt and Cocoa?
One part of our code is a set of about 150 different "settings" dialogs, which can be accessed in any applications as modal dialogs through a simple function call. Up to this point, this functionality is available only to Windows users, even though we provide our product on five other platforms.
I had no real difficulty in bringing a Qt dialog up inside a Cocoa application and having it active at the same time as the main Cocoa app. There were just a few issues to take care of:
1) I had to call "qt_mac_set_native_menubar(false)" at the right point to prevent Qt from taking over my application's menu bar.
2) The Qt event loop has to occur in the same thread as the main Cocoa event loop, from what I can tell. For this, I just scheduled an NSTimer to call QApplication::processEvents() periodically from the Cocoa application's run loop, in place of calling myQtApp.exec(). (I guess there'd be no need to even do this if I restrict my calls to use modal Qt dialogs.)
There are still issues with my work: I haven't done any intensive testing of the setup, and I need to find a way to get proper Carbon window references for the Qt windows if I want to get fancy, for example. However, initial results are very encouraging towards bringing Qt components into my Cocoa app in some form.