QProgressDialog dialog(tr("正在比对... ..."), tr("取消"), 0, 50000, this);
//dialog.setCancelButtonText(nullptr); //取消按钮隐藏
dialog.setWindowTitle(tr("图像学习"));
dialog.setWindowModality(Qt::WindowModal);
dialog.show();
for (int i = 0; i <= 50000; i++)
{
dialog.setValue(i);
QCoreApplication::processEvents();//界面冻结
if (dialog.wasCanceled()) break; //点击取消后立刻中断
}
//点击取消按钮后执行
if (dialog.wasCanceled())
{
QMessageBox::warning(NULL, QStringLiteral("提示"), QStringLiteral("保存失败"));
return;
}
QMessageBox::information(this, tr("系统提示"), tr("比对完成"), QMessageBox::Ok);
Qt弹出式进度条
于 2023-02-16 14:31:20 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)