当前位置:网站首页>[QT] timer
[QT] timer
2022-07-04 05:04:00 【StudyWinter】
1 The first way
(1) Using events void timerEvent ( QTimerEvent * ev)
(2) Start timer startTimer( 1000) Millisecond unit
(3)timerEvent The return value of is the unique identifier of the timer You can talk to ev->timerid compare
demand : Set two timers , Time is different .
(1) The first is rewriting timerEvent function
Add... Here UI Of label Control
rewrite
// Timer event
void Widget::timerEvent(QTimerEvent *event) {
if (event->timerId() == this->m_Id1) {
static int num = 1;
ui->label->setText(QString::number(num++));
} else if (event->timerId() == this->m_Id2){
static int num2 = 1;
ui->label_2->setText(QString::number(num2++));
}
}
(2) Because there are two timers , Add member attributes to the class , Each represents the return value of two timers
(3) Start two timers
// Start timer
this->m_Id1 = startTimer(1000); // millisecond
this->m_Id2 = startTimer(2000);
(4) effect
2 The second way
Timer class
// Timer class
QTimer* timer = new QTimer(this);
timer->start(500); // In milliseconds
// Monitor the signal of timer object
connect(timer, &QTimer::timeout, this, [=](){
static int num3 = 1;
ui->label_3->setText(QString::number(num3++));
});
effect
expand , Click the pause button , The timer pauses
add to QPushbutton Button , Use connect Make connections
// Click pause , Implementation stop
connect(ui->btn_pause, &QPushButton::clicked, this, [=](){
timer->stop();
});
effect
边栏推荐
- VSCode的有用插件
- The second case analysis of the breakthrough of defense system from the perspective of the red team
- [matlab] matlab simulation modulation system - DSB system
- 【MATLAB】通信信号调制通用函数 — 傅里叶逆变换
- 中科磐云—D模块解析以及评分标准
- 【QT】定时器
- Encryption and decryption
- Zhongke panyun-2022 Guangdong Trojan horse information acquisition and analysis
- KMP匹配字符串
- 【MATLAB】MATLAB 仿真数字基带传输系统 — 双极性基带信号(第 I 类部分响应波形)的眼图
猜你喜欢
海力士EMMC5.0及5.1系列对比详解
How to build your own knowledge engine? Community open application
Technology Management - learning / practice
中職組網絡安全—內存取證
电子元器件商城与数据手册下载网站汇总
appliedzkp zkevm(13)中的Public Inputs
Secondary vocational group network security - memory Forensics
Share some of my telecommuting experience
KMP匹配字符串
Zhengzhou zhengqingyuan Culture Communication Co., Ltd.: seven marketing skills for small enterprises
随机推荐
Annex 4: scoring criteria of the attacker docx
[matlab] matlab simulates digital bandpass transmission systems - QPSK and OQPSK systems
【MATLAB】MATLAB 仿真数字基带传输系统 — 数字基带传输系统
Public inputs in appliedzkp zkevm (13)
laravel 中获取刚刚插入的记录的id
[matlab] matlab simulation - simulate the AM modulation process of the modulation system
TCP状态转换图
Use units of measure in your code for a better life
The second case analysis of the breakthrough of defense system from the perspective of the red team
Create ASM disk through DD
Annex III: scoring standard of the defender docx
[matlab] general function of communication signal modulation - generation of narrow-band Gaussian white noise
[matlab] communication signal modulation general function interpolation function
QT qtableview data column width adaptation
Notes on the paper "cross view transformers for real time map view semantic segmentation"
PostgreSQL 正式超越 MySQL,这家伙也太强了吧!
Annexe VI: exposé sur les travaux de défense. Docx
Rollup各组件作用
RPC - grpc simple demo - learn / practice
【MATLAB】通信信号调制通用函数 — 低通滤波器