I have a non-Qt client in C++ that I cannot convert to Qt and I also have Qt library that I need to call from this client (all pieces are in Windows). I added couple of exported functions to my library that in turn are calling the global instances of my classes. Everything works fine, I can successfully call them from the straight C++ client. With one caveat - signals seems not to work. My QObject::connect calls all return true, signals are emitted (I can see that in the debugger), but they do not reach the recepient.

My suspicion is that I am not initializing the global event handling properly.
I am using QCoreApplication as a global variable and initialize it in the thread. My pseudo code in Qt library looks like this:

Qt Code:
  1. int _app_i = 1;
  2. char* _app_buf = "";
  3. QCoreApplication _app (_app_i, &_app_buf);
  4. ...
  5. extern "C"
  6. {
  7. bool start() // exported function
  8. {
  9. QThreadPool::globalInstance()->start(new appstarter() ); // see below the implementation of "run"
  10. return true;
  11. }
  12. }
  13.  
  14. void appstarter::run()
  15. {
  16. _app.exec();
  17. int i = 5; // I should not reach this line but I do!. According to docs the exec() call should only return after quit is called.
  18. }
To copy to clipboard, switch view to plain text mode 

I know that my library is not unloaded in the C++ client, because I can call other exported functions in any time and they are accessing other global variables, so _app instance exists.


I will appreciate suggestions/comments to help me solve the problem. As a start - why _app.exec() returns immediately?

Thanks