[Qt-interest] Making a Qt program into a dynamic library

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Tue Dec 15 17:28:21 CET 2009


Guido Seifert wrote on Tuesday, December 15, 2009 5:09 PM:

> > ... So my idea was to
> write a normal Qt program, rename the main function to something like
> 'start' and provide some sort of interface, so that the main program
> can control it. 

Okay, so I understand you are trying to have an "application within an application" of some sort, with its own event queue etc., so your "start" function (former main()) would e.g. look like this:

int start(int argc, char **argv) {
  QApplication app(argc, argv);
  ...
  // create your application window/dialogs, show them etc.
  ...
  return app.exec();
 }

I guess QApplication probably does not like that there is "something around it" (the application which dynamically links to the library and calls start()), so initialisation of the Qt event queue, resources etc. fails (maybe).

What about http://qt.nokia.com/doc/4.6/tutorials-widgets-toplevel.html, if you transform its main() into your start() and compile it with TEMPLATE=lib (as library), does that work with your approach? Is this what you are actually trying to do?


Cheers, Oliver
-- 
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22



More information about the Qt-interest-old mailing list