当前位置:网站首页>Day14QProgressBar2021-10-17
Day14QProgressBar2021-10-17
2022-06-22 02:44:00 【Morning and evening rain】
QProgrssBar—— Implementation of progress bar
The progress bar component combined with the timer will realize the simple application of the progress bar , This article will be published in Day3 Achieve content consistency , namely , single click start Button , The progress bar is incremented by one per second , single click end, Progress bar stop , Overflow from 10% Start . The difference is , Another way to realize it , Another way to write signals and slots , Provide more ideas for you to write large-scale projects .
Let's introduce Program implementation steps :
1.h Declare functions and variables in
public:
void Init();
void doProcessStart();
void doProcessEnd();
void doProcessTimeOut();
QTimer * myTimer;
int num;
2. Realization 、 Call initialization function Init();
//.cpp To realize
void MainWindow::Init()
{
num = 0;
connect(ui->btn_start,&QPushButton::clicked,this,&MainWindow::doProcessStart);
connect(ui->btn_end,&QPushButton::clicked,this,&MainWindow::doProcessEnd);
myTimer = new QTimer(this);
connect(myTimer,&QTimer::timeout,this,&MainWindow::doProcessTimeOut);
}
// Invocation in constructor
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
Init();
}
3. Realization doProcess function
void MainWindow::doProcessStart()
{
myTimer->start(1000);
}
void MainWindow::doProcessEnd()
{
myTimer->stop();
}
void MainWindow::doProcessTimeOut()
{
num++;
if(num==101)
{
num = 10;
}
ui->progressBar->setValue(num);
}
4. Code and effect ( Small scenario application )
single click start Button , Turn on timer ; single click end Button , off timer ; After the timer is turned on , The progress bar will appear in 1S Add for interval 1, When the progress bar is 100% when , from 10% Begin to continue .
边栏推荐
- Comprehensive interpretation by enterprise reviewers: enterprise growth of [State Grid] China Power Finance Co., Ltd
- Create RT_ Thread thread
- Brief analysis of application source code of neo4j intelligent supply chain
- 最新發布:Neo4j 圖數據科學 GDS 2.0 和 AuraDS GA
- Using OKR for HR digital transformation
- 【5. 高精度减法】
- [5. high precision subtraction]
- 【7. 高精度除法】
- Database daily question - day 19: top ranked travelers
- Informer有什么
猜你喜欢

Game jam development cycle

Select for i/0 multiplexing

使用 Neo4j 沙箱学习 Neo4j 图数据科学 GDS
![[2. merge sort]](/img/60/5e87cffabd91af0155ae681f5bf0ba.png)
[2. merge sort]

从数据库的分类说起,一文了解图数据库
![[5. high precision subtraction]](/img/87/52b154ba5816e1d6541c885b680a1f.png)
[5. high precision subtraction]

EMC整改小技巧
![[proteus simulation] INT0 and INT1 interrupt count](/img/0b/b3f5adb97046d927e501ea34deb3d9.png)
[proteus simulation] INT0 and INT1 interrupt count
![[3. binary integer and floating point number]](/img/82/6c3ef250b90d875cddaebc5bd4a4b8.png)
[3. binary integer and floating point number]

Architecture and practice of vivo container cluster monitoring system
随机推荐
Which Amazon evaluation system is better?
Penetration testing - logic vulnerability topic
Graphacademy course explanation: Fundamentals of neo4j graph data science
Wechat applet film and television comment exchange platform system graduation design (3) background function
Game Jam开发周期
【2. 归并排序】
In 2022, the number of mobile banking users in Q1 will reach 650million, and ESG personal financial product innovation will be strengthened
微软 IE 浏览器于 6 月 15 日被永久关闭
rt_ Thread thread management
Parallel search DSU
June25,2022 PMP Exam clearance manual-3
【5. 高精度减法】
Ioerror: no translation files found for default language zh cn Solutions for
Must the database primary key be self incremented? What scenarios do not suggest self augmentation?
In the era of industrial Internet, there is no real center
Live broadcast on June 22 | zhanzhihui, South China Institute of Technology: evolutionary computing for expensive optimization
fatal error: png++/png. Hpp: no that file or directory
Asemi fast recovery diode FR107 parameter, FR107 real object, FR107 application
MySQL recursively finds the tree structure. This method is very practical!
如何选择合适的 Neo4j 版本(2022版)