class MyClass {
QFutureWatcher mWatcher;
};
MyClass::MyClass() {
connect(&mWatcher, SIGNAL(finished()), &mProgress, SLOT(reset()));
connect(&mWatcher, SIGNAL(progressValueChanged(int)), &mProgress, SLOT(setValue(int)));
connect(&mWatcher, SIGNAL(progressRangeChanged(int,int)), &mProgress, SLOT(setRange(int,int)));
connect(&mProgress, SIGNAL(canceled()), &mWatcher, SLOT(cancel()));
connect(&mWatcher, SIGNAL(canceled()), &mProgress, SLOT(cancel()));
}
void MyClass::calculate() {
mWatcher.setFuture(QtConcurrent::map(begin(), end(), Calculator()));
}
class MyClass {
QProgressDialog mProgress;
QFutureWatcher mWatcher;
};
MyClass::MyClass() {
connect(&mWatcher, SIGNAL(finished()), &mProgress, SLOT(reset()));
connect(&mWatcher, SIGNAL(progressValueChanged(int)), &mProgress, SLOT(setValue(int)));
connect(&mWatcher, SIGNAL(progressRangeChanged(int,int)), &mProgress, SLOT(setRange(int,int)));
connect(&mProgress, SIGNAL(canceled()), &mWatcher, SLOT(cancel()));
connect(&mWatcher, SIGNAL(canceled()), &mProgress, SLOT(cancel()));
}
void MyClass::calculate() {
mWatcher.setFuture(QtConcurrent::map(begin(), end(), Calculator()));
}
To copy to clipboard, switch view to plain text mode
Bookmarks