PDA

View Full Version : How to do Qt UI in a DLL used by Qt / Non-QT apps



cboles
25th August 2008, 18:37
I am creating a DLL (and perhaps a dylib for OSX) that interfaces to some hardware that for the most part has no UI at all. If the DLL detects that the hardware's firmware is out of date, I want it to be able to pop up some simple message boxes to get the user's approval to update the firmware.

So for my DLL to do this via Qt, it needs to have a QApplication and a QApplication::exec() loop running right? The problem is, the hosting app may be:

(1) A Qt based application already running its own QApplication loop - how would I detect and use this?

(2) A non-Qt application running its own message loop of some form. How do I join this message loop? Or can I just start my own QApplication loop in another thread?

(3) A non-Qt application with no message loop (e.g. a console app). Is it possible for my DLL to start a GUI from inside a console app?

Thanks,

Colby

ktk
25th August 2008, 22:02
That's going to be a very bumpy ride... I am looking at this from a Linux
perspective with limited insight in Qt on Windows. So as this highly
platform dependent, take it with a grain of salt. Or maybe two...

(3) That's probably the simplest case. This should just work,
possibly after fiddling a bit with compiler/linker settings.

(2) should also "work" if you don't care about a responsive main application
while the Qt dialog runs. This might be ok but will look unprofessional.
For proper event loop interaction you'll need a toolkit specific solution like
http://trolltech.com/products/qt/addons/catalog/4/Windows/qtwinmigrate.
There's something similar for Motif applications.

(1) Qt-plugin in Qt-application. If it's the same version of Qt I'd
try to avoid to instantiate a second QApplication in the dll and
work with the QApplication in the hosting application. That should
work. I have a suspicion that everything else will get really ugly.

Of course, fitting everything of that into a single .dll will be a
challenge of its own ;-}