PDA

View Full Version : Connects and threads in a dll



greenvirag
18th September 2008, 17:43
I have a special problem, I think, so I would like to ask help from someone who is well up in qt.

The situation is: there is a dll file, called myprog.dll . I would like to use it from an another program, called callerprog.

In myprog.dll there are threads and some standalone static objects. The standalone objects and some objects in the threads are communicating by the help of connects.

I call some functions defined in the dll.
But: in the dll it is QApplication needed because of starting event handling.
So I make a static QApplication variable, and call its exec() function. But QApplication is a main event loop and it waits until exit(), so collerprog can't make anything until QApplication's exit()/quit().

I would like to run some functions in the dll, but I wouldn't like to wait for its end. E.g. a good work maybe:

...
[callerprog: ] functionInDll();
[mydll: ] start working, start event handling
[callerprog: ] dosomething();
..
[callerprog: ] getTheSolutionFromTheDll();


What can be a good method for the above?
I think QApplication not. But what else, which can satisfy the event handling condition?


Thank you very well for the answers.

greenvirag
22nd September 2008, 08:02
Up.

Don't idea?

jpn
22nd September 2008, 08:21
You should not create a static QApplication instance in the library code. The library should assert that the client has created an application object. Furthermore, it's not that good idea to start working independently in the library code when some static object gets constructed. Rather, you should offer a control function for the client to decide when to start working. At that point it is perfectly valid to rely on that the client has instantiated an application object as well.

greenvirag
22nd September 2008, 08:39
Thank you for your comment, but as I see, it is about architectural problem.
I will think about it, but my question about event handling is still unanswered:

can I start event handling without QApplication?
could I retun from the library after starting QApplication::exec() /or other way starting the main loop/ to the caller program?