Hi,
I am trying to run a class's void function called "show()", here is code:
in main.cpp
MyClassObj* cObj;
for (int i=0 ; i<=vecObj.count() ; i++)
{
cObj=&vecObj[i][0];
cObj->moveToThread(&thread);
cObj->connect(&thread,SIGNAL(started()),SLOT(show()));
thread.connect(&thread,SIGNAL(finished()),&thread,SLOT(quit()));
thread.start();
thread.wait();
}
MyClassObj* cObj;
QThread thread;
for (int i=0 ; i<=vecObj.count() ; i++)
{
cObj=&vecObj[i][0];
cObj->moveToThread(&thread);
cObj->connect(&thread,SIGNAL(started()),SLOT(show()));
thread.connect(&thread,SIGNAL(finished()),&thread,SLOT(quit()));
thread.start();
thread.wait();
}
To copy to clipboard, switch view to plain text mode
now issue is, this code runs fine for the first loop, but since thread.wait() is called at the end of loop, thread waits for execution to stop (waiting for thread.quit()) after first loop and i am not able "resume" this wait() condition so that show() is called again for next loop.
I am kinda stuck here, i have been going through many articles and forum discussion, haven't found any issue like this.
Any help will be greatfully appreciated.
Thanks in advance.
Bookmarks