Women in Technology

Hear us Roar



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.


I'm currently working with Qt/Mac and wonder about mixed Qt and Cocoa applications. So if you can point me towards any docs on that, or will cover it in your series, please let me know.


Thanks!

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • Request: Mixing Qt and Cocoa?
    2007-06-18 10:30:50  ghiebert [View]

    I've been playing around with Qt for the past week, after some interest was shown at work of moving our MFC- and Delphi-based code over to Qt.

    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.
  • Jeremiah Foster photo Request: Mixing Qt and Cocoa?
    2007-05-17 04:38:43  Jeremiah Foster | O'Reilly Blogger [View]

    Thank you for the comment. I am glad you find the article useful, at least I hope it was useful, and yes, I am going to be covering Qt shortly.

    As far as combining the Cocoa and Qt systems I am a little skeptical. Could you explain more about how you would combine the two? Using Cocoa you can access Quartz and Core Foundations of the OS directly in an efficient manner which would obviate the need to Qt. But perhaps you have some Qt code that you want to use on the OS X platform - in that case I would look and see if you can use Qt and Objective-C together. Then you can have the cross platform windowing of Qt and the logic in Obj-C. If you intend to use that on another platform you need to make sure Obj-C is available on your chosen platform, which I think is available under Linux but I am unsure about Windows.

    Regards,

    Jeremiah