views:

182

answers:

1

I am writing a plugin for another application. I want to support the plugin on multiple platforms, so I am strongly considering using Qt.

The plugin needs to be able to show some basic GUI. The plugin interface does not in any way handle GUI - it is just a simple DLL/shared library specified with a C-header file.

Can I use Qt inside such a shared library? The calling application might or might not be using Qt itself. Any hints on what to do? Do I need to run a QApplication event-loop in a separate thread? Or can I just call the event-loop myself while waiting for input? (I only need modal dialogs).

A: 

I don't think it is possible because you need to create the QApplication eventloop in the main thread.

Note that QCoreApplication::exec() must always be called from the main thread (the thread that executes main()), not from a QThread. In GUI applications, the main thread is also called the GUI thread because it's the only thread that is allowed to perform GUI-related operations.

TimW
I could start a non-QT thread to host the QApplication. It is probably not supported, but I can't see why it shouldn't work.
Rasmus Faber
Here is a discussion of a similar problem: http://stackoverflow.com/questions/1051333/combing-an-external-event-loop-with-qts
torque