进度条功能demo项目完整代码:MyTimer界面功能点击start进度条开始刷新,pause暂停,stop停止并清空进度条;点击button后修改使能状态。实现思路:定时器超时后,计数+1,更新progressBar的值。主要代码:12345678910111213141516171819void MainWindow::init(){ myTimer = new QTimer(); cnt = 0; ui->progressBar->setValue(cnt); // ... connect(this->myTimer, SIGNAL(timeout()), this, SLOT(flushBar()));}void MainWindow::flushBar(){ ++cnt; ui->progressBar->setValue(cnt); if(cnt == 100) { QMessageBox::information(this, "Timer", "Done!"); on_stopButton_clicked(); }} QT #QT进度条功能demohttps://ww1820.github.io/posts/f2585515/作者AWei发布于2023年6月2日更新于2023年6月2日许可协议 记事本功能 上一篇鼠标点击事件demo 下一篇