Qt弹出式进度条

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,开发语言)