当前位置:网站首页>[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

边栏推荐
- Annex 2-2 confidentiality commitment docx
- 【MATLAB】MATLAB 仿真数字带通传输系统 — ASK、 PSK、 FSK 系统
- Use units of measure in your code for a better life
- Zhongke Panyun - module a infrastructure setting and safety reinforcement scoring standard
- VSCode的有用插件
- Annex II: confidentiality agreement for offensive and defensive drills docx
- [matlab] general function of communication signal modulation inverse Fourier transform
- The paddlehub face recognition scheme is deployed, and the trained model is deployed and applied in pytchrom
- 红队视角下的防御体系突破之第一篇介绍、阶段、方法
- Secondary vocational group network security - memory Forensics
猜你喜欢
随机推荐
【MATLAB】MATLAB 仿真 — 窄带高斯白噪声
附件五:攻击过程简报.docx
【MATLAB】MATLAB 仿真模拟调制系统 — DSB 系统
National vocational college skills competition (secondary vocational group) network security competition questions - Analysis
【MATLAB】通信信号调制通用函数 — 窄带高斯白噪声的生成
Fault analysis | mongodb 5.0 reports an error, and the legal instruction solves it
Simple g++ and GDB debugging
Network equipment emergency response Guide
cmake
海力士EMMC5.0及5.1系列对比详解
红队视角下的防御体系突破之第一篇介绍、阶段、方法
附件六:防守工作簡報.docx
cmake
Zkevm (12) state proof of appliedzkp
中科磐云—D模块解析以及评分标准
【MATLAB】通信信号调制通用函数 — 插值函数
【MATLAB】MATLAB 仿真模拟调制系统 — SSB 系统
我们认为消费互联网发展到最后,依然会局限于互联网行业本身
6-4 vulnerability exploitation SSH banner information acquisition
[matlab] general function of communication signal modulation Fourier transform

![[技术发展-25]:广播电视网、互联网、电信网、电网四网融合技术](/img/87/e0469e280365ed0261e2b551ebd888.png)







