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:
int _app_i = 1;
char* _app_buf = "";
...
extern "C"
{
bool start() // exported function
{
QThreadPool::globalInstance()->start(new appstarter() ); // see below the implementation of "run"
return true;
}
}
void appstarter::run()
{
_app.exec();
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.
}
int _app_i = 1;
char* _app_buf = "";
QCoreApplication _app (_app_i, &_app_buf);
...
extern "C"
{
bool start() // exported function
{
QThreadPool::globalInstance()->start(new appstarter() ); // see below the implementation of "run"
return true;
}
}
void appstarter::run()
{
_app.exec();
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.
}
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
Bookmarks