我的问题是,当我点击取消按钮时,QProgressDialog关闭,我向任务发送消息取消,但是当我运行MainWindow的任务保持锁定状态时。当我的任务没有收到取消消息时,是否有选项不关闭QProgressDialog?
progressDialog->setMaximum(0);
progressDialog->setMinimum(0);
progressDialog->setWindowTitle(QString::fromStdString(title));
progressDialog->setLabelText(QString::fromStdString(text));
QFutureWatcher<void> futureWatcher;
QObject::connect(&futureWatcher, SIGNAL(finished()), progressDialog.get(), SLOT(reset()));
QObject::connect(progressDialog.get(), SIGNAL(canceled()), this, SLOT(cancel()));
QObject::connect(progressDialog.get(), SIGNAL(canceled()), &futureWatcher, SLOT(cancel()));
// Start the computation.
futureWatcher.setFuture(QtConcurrent::run(func));
// Display the dialog and start the event loop.
progressDialog->exec();
futureWatcher.waitForFinished();
感谢&#39; S