void MainWindow::on_pushButton_clicked()
{
QProgressDialog dialog(tr("文件复制进度"), tr("取消"), 0, 5000, this);
dialog.setWindowTitle(tr("进度对话框"));
dialog.setWindowModality(Qt::WindowModal);
dialog.show();
dialog.setLabelText("111111");
std::this_thread::sleep_for(std::chrono::seconds(5));
dialog.setValue(1000);
dialog.setLabelText("222222");
std::this_thread::sleep_for(std::chrono::seconds(5));
dialog.setValue(2000);
dialog.setLabelText("333333");
std::this_thread::sleep_for(std::chrono::seconds(5));
dialog.setValue(3000);
dialog.setLabelText("444444");
std::this_thread::sleep_for(std::chrono::seconds(5));
dialog.setValue(4000);
dialog.setLabelText("555555");
std::this_thread::sleep_for(std::chrono::seconds(5));
// for(int i = 0; i < 50000; i+1000)//已知最大值不超过50000
// {
// thread t1{Counter};
// if(t1.joinable())
// t1.join();
// dialog.setValue(i);
// dialog.setLabelText("111111");
// QCoreApplication::processEvents();
// if(dialog.wasCanceled())
// break;
// }
dialog.setValue(5000);
qDebug()<<tr("复制结束!");
}
Qt进度简单提示
最新推荐文章于 2024-07-27 16:16:05 发布