1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| void ProcessProg::run(){
Displayer* d = new Displayer();
vector<QThread*> tabThreads;
QObject::connect(this, SIGNAL(askDisplayMat(int)),d, SLOT(displayMat(int)));
emit askDisplayMat(1); // This emit works, the signal is catched by the displayer
for (int i = 0; i < 2; i++)
{
/// We create and run a new Thread
QThread* thread = new QThread;
MyObject* obj = new MyObject();
obj->moveToThread(thread);
QObject::connect(thread, SIGNAL(started()), obj, SLOT(process()));
QObject::connect(obj, SIGNAL(askDisplayMat(int)),d, SLOT(displayMat(int)));
QObject::connect(obj, SIGNAL(finished()), thread, SLOT(quit()));
QObject::connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
thread->start();
tabThreads.push_back(thread);
}
/// We wait until all the tracker finish
for(int j = 0;j < tabThreads.size(); j++)
{
(QThread*)(tabThreads.at(j))->wait();
}
/// Empty the tabThreead
tabThreads.clear();
exit(0);
} |
Partager