0

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).

Rasmus Faber
  • 48,631
  • 24
  • 141
  • 189
  • Why not accept the answers to some of your other Qt questions? I know for a fact that at least one of them, the QtCreator/MSVC one, had good answers. – rpg Oct 12 '09 at 14:15
  • Thanks for reminding me. I was putting it off, since there were several good answers and it was hard selecting a "best" one. – Rasmus Faber Oct 12 '09 at 17:39

1 Answers1

0

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
  • 8,351
  • 1
  • 29
  • 33
  • 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 Oct 12 '09 at 11:39
  • 2
    Here is a discussion of a similar problem: http://stackoverflow.com/questions/1051333/combing-an-external-event-loop-with-qts – torque Oct 12 '09 at 12:14