Results 1 to 4 of 4

Thread: Connects and threads in a dll

  1. #1
    Join Date
    Sep 2008
    Posts
    17
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Connects and threads in a dll

    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.

  2. #2
    Join Date
    Sep 2008
    Posts
    17
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Connects and threads in a dll

    Up.

    Don't idea?

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Connects and threads in a dll

    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.
    J-P Nurmi

  4. #4
    Join Date
    Sep 2008
    Posts
    17
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Connects and threads in a dll

    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?

Similar Threads

  1. Connecting signals & slots across different threads
    By jyoti kumar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 12:40
  2. QMessageBox and threads
    By vfernandez in forum Qt Programming
    Replies: 3
    Last Post: 5th February 2006, 17:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.