Qt进度简单提示

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("复制结束!");
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

苦逼的IT男

你的鼓励是我最大的创作动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值