当前位置:网站首页>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 .
边栏推荐
- Linxu modify the permissions of the folder so that everyone can access 777
- PostgreSQL fetches data according to the size of the time field
- Huayang smart rushes to Shenzhen Stock Exchange: it plans to raise 400million Fosun Weiying as a shareholder
- Official release of ideal L9: retail price of 459800 yuan will be delivered before the end of August
- Li Kou today's question 1108 IP address invalidation
- Programming of pytorch interface
- FPGA Xilinx 7 Series FPGA DDR3 hardware design rules
- Wechat applet film and television review and exchange platform system graduation design completion (7) Interim inspection report
- Microblog closes publishing multiple part-time fraud information illegal accounts: how to crack down on data fraud
- 【7. 高精度除法】
猜你喜欢

fatal error: png++/png. Hpp: no that file or directory

On Monday, I asked the meaning of the | -leaf attribute?

从数据库的分类说起,一文了解图数据库

【一起上水硕系列】Day Two

MySQL recursively finds the tree structure. This method is very practical!

Wechat applet film and television comment exchange platform system graduation design (3) background function

Unity3d post process volume profile

关于PMP考试,你想知道的知识都在这里了

What is a neural network

Chapter 24 image and video processing based on Simulink -- matlab in-depth learning and practical collation
随机推荐
Wechat applet film and television comment exchange platform system graduation design (3) background function
Starting from the classification of database, I understand the graph database
C ++ Primer 第2章 变量和基本类型 总结
Wechat applet film and television review and exchange platform system graduation design completion (7) Interim inspection report
PostgreSQL fetches data according to the size of the time field
On Monday, I asked the meaning of the | -leaf attribute?
Parallel search DSU
Asemi fast recovery diode FR107 parameter, FR107 real object, FR107 application
[6. high precision multiplication]
Zap grammar sugar
C # judge whether the application is started and displayed
Introduction to Apache ActiveMQ Artemis
Huayang smart rushes to Shenzhen Stock Exchange: it plans to raise 400million Fosun Weiying as a shareholder
Wechat applet film and television comment exchange platform system graduation design (2) applet function
With the acceleration of industry wide digital transformation, what kind of storage will be more popular?
Introduction to excellent verilog/fpga open source project (XXVII) - small CPU
Chapter 24 image and video processing based on Simulink -- matlab in-depth learning and practical collation
fatal error: png++/png. Hpp: no that file or directory
An article thoroughly learns to draw data flow diagrams
import和require在浏览器和node环境下的实现差异