template <typename Class, typename T>QFuture<T> run(void (Class::*fn)(QFutureInterface<T> &), Class *object);
C++ (Qt)futureInterface.setProgressValueAndText(100, "C-CDA document export finished!");
C++ (Qt)void BackgroundWorkDialog::setFuture(const QFuture<void> &future){ myProcessWatcher.setFuture(future); // Connect signals connect(&myProcessWatcher, SIGNAL(progressValueChanged(int)), progressBar, SLOT(setValue(int))); connect(&myProcessWatcher, SIGNAL(progressTextChanged(QString)), label, SLOT(setText(QString))); connect(&myProcessWatcher, SIGNAL(finished()), this, SLOT(proccessFinish()));} void BackgroundWorkDialog::proccessFinish(){ // disconnect dialog hiding disconnect(button, SIGNAL(clicked()), this, SLOT(hide())); if(isHidden()) show(); button->setText("Done!"); connect(button, SIGNAL(clicked()), this, SLOT(accept())); connect(this, SIGNAL(accepted()), this, SLOT(deleteLater())); connect(this, SIGNAL(rejected()), this, SLOT(deleteLater())); emit finished();}
C++ (Qt) reportProgress(10, "Generating ... section..."); ... reportProgress(100, "Document export finished!");
C++ (Qt)void XMLReport::reportProgress(int progressValue, const QString &message){ future().setProgressValueAndText(progressValue, message); emit progressValueChanged(progressValue); if(!message.isEmpty()) emit progressTextChanged(message);}