void ThreadWatcher2::run() {
for (int i=0; i<6; i++) {
connect(thread[i], SIGNAL(finished()), &signalMapper, SLOT(map()));
signalMapper.setMapping(thread[i], i); }
connect(&signalMapper, SIGNAL(mapped(int)), this, SLOT(finishedHandler(int)));
connect(updateTimer, SIGNAL(timeout()), this, SLOT(timeoutHandler()));
updateTimer->start(10);
}
void ThreadWatcher2::timeoutHandler() {
for (int i=0; i<6; i++)
window[i]->update();
updateTimer->stop();
updateTimer->start(10);
if (threadsLeft==0)
}
void ThreadWatcher2::finishedHandler(int t) {
threadsLeft--;
cout << "t: " << t << endl;
}
void ThreadWatcher2::run() {
updateTimer = new QTimer();
QSignalMapper signalMapper;
for (int i=0; i<6; i++) {
connect(thread[i], SIGNAL(finished()), &signalMapper, SLOT(map()));
signalMapper.setMapping(thread[i], i); }
connect(&signalMapper, SIGNAL(mapped(int)), this, SLOT(finishedHandler(int)));
connect(updateTimer, SIGNAL(timeout()), this, SLOT(timeoutHandler()));
updateTimer->start(10);
QThread::exec();
}
void ThreadWatcher2::timeoutHandler() {
for (int i=0; i<6; i++)
window[i]->update();
updateTimer->stop();
updateTimer->start(10);
if (threadsLeft==0)
QThread::exit(0);
}
void ThreadWatcher2::finishedHandler(int t) {
threadsLeft--;
QTextStream cout(stdout, QIODevice::WriteOnly);
cout << "t: " << t << endl;
}
To copy to clipboard, switch view to plain text mode
Bookmarks