[Qt-interest] Using a Qt class in a non-Qt app?

Richard richardmg at trolltech.com
Thu Oct 1 14:56:43 CEST 2009


>
> The problem I am having is that my slots are not getting called which
> I think is because I do not have a QApplication. Therefore, there
> isn't an application run loop dispatching these events.
>
> I could add such a thing, but then I would short circuit the
> NSApplication object that Cocoa uses.
>
> Any idea as to what I should do here?

You should create QApplication, but you don't need to call exec on it.  
If you call [NSApplication run] or NSApplicationMain(...) from your  
application (after creating QApplication), those calls will take care  
of processing Qt events as well. You will also like to set  
QApplication::setAttribute(Qt::AA_MacPluginApplication), and perhaps  
take a look at QMacNativeWidget and QMacCocoaViewContainer.

Regards
Richard

(NB: Using Qt like this, as a 'plugin' from a Cocoa app, has some  
issues in Qt-4.5 (regarding modality etc). These are fixed for Qt-4.6) 



More information about the Qt-interest-old mailing list