当前位置:网站首页>About the problems encountered when using the timer class to stop with a button (why does the QPushButton (for the first time) need to be clicked twice to respond?)
About the problems encountered when using the timer class to stop with a button (why does the QPushButton (for the first time) need to be clicked twice to respond?)
2022-06-30 14:06:00 【Fat Xiao Deng】
Why? QPushButton( for the first time ) It takes two clicks to respond ?
I found a problem when learning the timer class ( I wonder if ?).
ask : When clicking pause 1 when , Mouse to double-click , The timer will stop , see Qt Assistant pair clicked Obviously not 
translate : When the button is activated ( namely , Press and release when the mouse cursor is inside the button ), When you type a shortcut key , Or when click() or animateClick() When called , This signal is sent . It is worth noting that , If the setDown()、setChecked() or toggle(), This signal will not be sent .
understand : Shouldn't it be a mouse click ?

#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
// Create a timer object
timer1 = new QTimer(this);
timer2 = new QTimer(this);
// Object on
timer1->start(500);
timer2->start(1000);
int num1=0;
int num2=0;
// When the timer is turned on, a timeout The signal
connect(timer1,&QTimer::timeout,[=]()mutable{
ui->label->setText(QString::number(num1++));
});
connect(timer2,&QTimer::timeout,[=]()mutable{
ui->label_2->setText(QString::number(num2++));
});
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_pushButton_clicked()// Pause 1
{
connect(ui->pushButton, &QPushButton::clicked,this,[=](){
timer1->stop();// Click twice to stop ???
});
}
void Widget::on_pushButton_2_clicked()// continue 1
{
connect(ui->pushButton_2, &QPushButton::clicked,this,[=](){
timer1->start(500);
});
}
** attach :** This is my in windows Up operation Qt(5.7.0) When I met
** reflection :** This sum doubleClicked What's the difference ?
This signal is emitted when the button is interactively double clicked by the user.
When the user interactively double clicks the button , Will send this signal .
Now record .
** solve :** The above problem is caused by turning to the slot , If you write the code of clicking the button into the constructor, there will be no problem .
边栏推荐
- Paper interpretation (AGC) attributed graph clustering via adaptive graph revolution
- get请求与post提交区别的简易理解
- Shell programming overview
- 提权扫描工具
- MySQL如何将列合并?
- IM即时通讯应用开发中无法解决的“顽疾”
- Prometheus 2.29.0 new features
- When SQL queries are performed in table storage, an error is reported when the primary key is added to the query result, and the query result exceeds 10W rows. Do you want to add multiple indexes to t
- I want to ask how to open an account at China Merchants Securities? Is it safe to open a stock account through the link
- Tencent two sides: @bean and @component are used on the same class. What happens?
猜你喜欢

Getting started with shell Basics

Step by step | help you easily submit Google play data security form
![【科研数据处理】[实践]类别变量频数分析图表、数值变量分布图表与正态性检验(包含对数正态)](/img/5a/eaa845f4332f0b8ee8b6409d6a79e8.png)
【科研数据处理】[实践]类别变量频数分析图表、数值变量分布图表与正态性检验(包含对数正态)

步骤详解 | 助您轻松提交 Google Play 数据安全表单

编程实战赛来啦!B站周边、高级会员等好礼送你啦!

Google Earth engine (GEE) -- converts string to number and applies it to time search (ee.date.fromymd)

Waving flags and shouting for basic language

SQL考勤统计月报表

"Persistent diseases" that cannot be solved in IM application development

Google Earth Engine(GEE)——将字符串的转化为数字并且应用于时间搜索( ee.Date.fromYMD)
随机推荐
嵌入式开发:5个可能不再被禁止的C特征
WTM major updates, multi tenancy and single sign on
Deep understanding Net (2) kernel mode 3 Kernel mode construct mutex
Step by step | help you easily submit Google play data security form
Multi terminal collaboration of Huawei accounts to create a better internet life
一条查询SQL是如何执行的
【科研数据处理】[基础]类别变量频数分析图表、数值变量分布图表与正态性检验(包含对数正态)
golang模板(text/template)
这个编辑器即将开源!
This article explains the concepts of typed array, arraybuffer, typedarray, DataView, etc
[recruitment (Guangzhou)] Chenggong Yi (Guangzhou) Net core middle and Senior Development Engineer
幸运哈希竞猜系统开发(源码部署)趣投哈希游戏玩法开发(案例需求)
深入理解.Net中的线程同步之构造模式(二)内核模式3.内核模式构造物Mutex
步骤详解 | 助您轻松提交 Google Play 数据安全表单
Paper interpretation (AGC) attributed graph clustering via adaptive graph revolution
I'd like to ask you, where can I open an account in Foshan? Is it safe to open a mobile account?
想請教一下,我在佛山,到哪裏開戶比較好?手機開戶是安全麼?
Dart extended feature
Intelligent operation and maintenance: visual management system based on BIM Technology
【Kubernetes系列】K8s设置MySQL8大小写不敏感