定时器以及定时器事件
来源:互联网 发布:软件前端开发是什么 编辑:程序博客网 时间:2024/05/23 07:24
widget.h
#include <QWidget>#include<QTimer>class Widget : public QWidget{ Q_OBJECTpublic: Widget(QWidget *parent = 0); ~Widget();protected: void timerEvent(QTimerEvent *);private: QTimer *timer; int timeId_1000; int timeId_3000;};
widget.cpp
#include "widget.h"#include<QTimerEvent>#include<QDebug>Widget::Widget(QWidget *parent) : QWidget(parent){ timer=new QTimer(this); timer->setInterval(1000); timer->start(); // connect(timer, SIGNAL(timeout()), this, SLOT(close())); timeId_1000 = startTimer(1000); timeId_3000 = startTimer(3000);}Widget::~Widget(){}void Widget::timerEvent(QTimerEvent *event){ static int counter = 0; if( event->timerId() == timeId_1000 ) { qDebug()<<"1000 timeout"; counter++; if(counter == 5) { killTimer(timeId_1000); } }// if(event->timerId() == timeId_3000)// {// qDebug()<<"3000 timeout";// counter++;// if(counter == 5)// {// killTimer(timeId_3000);// }// }}
阅读全文
0 0
- 定时器以及定时器事件
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 图像分割系列文章
- 关于NIO的那些事儿
- 统计学习方法概述
- 解决 {"ret":100030,"msg":"this api without user authorization"} android QQ第三发登录成功后获取用户信息失败的问题
- 仿微信二维码扫描自定义view
- 定时器以及定时器事件
- p4设置host
- Linux 常用命令一览
- 在IDEA中实战Git
- Support Webpage for GPS Map Ruler
- mybatis的statement的解析与加载
- Oracle 10.2.0.5 4节点RAC主机(HP rx7640小型机)emcpMpxError故障处理
- 多种方式批量安装操作系统
- 样本间相似度/距离计算方法总结