当前位置: 首页 > news >正文

手机开发者选项在哪里找seo包年优化平台

手机开发者选项在哪里找,seo包年优化平台,住房和建设部信息网站,湖北建筑网一、说明 在Qt中常使用如下两种定时器 1、使用QObiect类的定时器事件QTimerEvent 与定时器相关的函数有#xff1a;startTimer()、timeEvent()、killTimer()#xff1b;startTimer(int interval)函数开始一个定时器并返回定时器ID#xff0c;如果不能开始一个定时器…一、说明 在Qt中常使用如下两种定时器 1、使用QObiect类的定时器事件QTimerEvent 与定时器相关的函数有startTimer()、timeEvent()、killTimer()startTimer(int interval)函数开始一个定时器并返回定时器ID如果不能开始一个定时器将返回0。定时器开始后每隔interval毫秒间隔将触发一次超时事件超时事件由timerEvent函数处理在timerEvent函数中通过定时器ID来区分不同的定时器使用killTimer ( int id )停止定时器id就是要停止定时器的ID。 2、使用QTimer类 首先创建一个定时器类的对象QTimer *timer new QTimer(this); 使用timer-setInterval(int msec)提前设置定时器时间或者使用timer-start(std::chrono::milliseconds msec)在定时器开始时设置时间 在定时器开始msec毫秒后timer 后会发出timeout()信号所以在创建好定时器对象后给其建立信号与槽连接connect(timer, SIGNAL(timeout()), this, SLOT(onTimeout())); 在超时槽函数onTimeout()里面做超时处理。 在需要开启定时器的地方调用timer-start(1000); 使用timer-stop();停止定时器。 注void QTimer::singleShot(int msec, const QObject *receiver, const char *member) 这个静态函数进行一次定时器的使用在msec毫秒后调用槽函数member如下示例程序在6秒后自动终止 QApplication app(argc, argv); QTimer::singleShot(6000, app, SLOT(quit())); ... return app.exec(); 二、QTimerEvent使用 创建一个Qt项目基类选择QMainWindow 在界面上放置如下控件并修改objectName 修改.h代码如下声明两个整型变量m_timer1Id、m_timer2Id用来存储定时器ID #ifndef MAINWINDOW_H #define MAINWINDOW_H#include QMainWindownamespace Ui { class MainWindow; }class MainWindow : public QMainWindow {Q_OBJECTpublic:explicit MainWindow(QWidget *parent nullptr);~MainWindow();protected:void timerEvent(QTimerEvent* event); //定时器事件private slots:void on_startPushButton1_clicked();void on_stopPushButton1_clicked();void on_startPushButton2_clicked();void on_stopPushButton2_clicked();private:Ui::MainWindow *ui;int m_timer1Id; //定时器1IDint m_timer2Id; //定时器2ID };#endif // MAINWINDOW_H修改.cpp代码如下四个摁键控制两个定时器的开始和停止timerEvent函数进行定时器超时事件的处理 #include mainwindow.h #include ui_mainwindow.h #include QDebug #include QTimeMainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWindow) {ui-setupUi(this); }MainWindow::~MainWindow() {delete ui; }void MainWindow::timerEvent(QTimerEvent *event) {//使用定时器ID区分定时器if(event-timerId() m_timer1Id){qDebug() 定时器1 QTime::currentTime().toString(hh:mm:ss);}else if(event-timerId() m_timer2Id){qDebug() 定时器2 QTime::currentTime().toString(hh:mm:ss);} }void MainWindow::on_startPushButton1_clicked() {m_timer1Id startTimer(1000*3); //3秒定时器qDebug() 定时器1开始 QTime::currentTime().toString(hh:mm:ss); }void MainWindow::on_stopPushButton1_clicked() {killTimer(m_timer1Id);qDebug() 定时器1停止 QTime::currentTime().toString(hh:mm:ss); }void MainWindow::on_startPushButton2_clicked() {m_timer2Id startTimer(1000*5); //5秒定时器qDebug() 定时器2开始 QTime::currentTime().toString(hh:mm:ss); }void MainWindow::on_stopPushButton2_clicked() {killTimer(m_timer2Id);qDebug() 定时器2停止 QTime::currentTime().toString(hh:mm:ss); }运行程序点击“开始”“开始”等一会点击“停止”“停止” 输出内容如下定时器1每隔3秒输出一次定时器2每隔5秒输出一次符合程序设定 三、QTimer使用 创建一个Qt项目基类选择QMainWindow 在界面上放置如下控件并修改objectName 修改.h代码声明两个QTimer对象m_timer1、m_timer2和两个超时处理槽函数onTimerOut1、onTimerOut2 #ifndef MAINWINDOW_H #define MAINWINDOW_H#include QMainWindow #include QTimernamespace Ui { class MainWindow; }class MainWindow : public QMainWindow {Q_OBJECTpublic:explicit MainWindow(QWidget *parent nullptr);~MainWindow();private slots:void on_startPushButton1_clicked();void on_stopPushButton1_clicked();void onTimerOut1();void on_startPushButton2_clicked();void on_stopPushButton2_clicked();void onTimerOut2();private:Ui::MainWindow *ui;QTimer *m_timer1;QTimer *m_timer2; };#endif // MAINWINDOW_H修改.cpp代码在构造函数中对两个QTimer对象进行初始化并绑定槽函数四个摁键控制两个定时器的开始和停止onTimerOut1和onTimerOut2函数进行定时器超时事件的处理 #include mainwindow.h #include ui_mainwindow.h #include QTime #include QDebugMainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWindow) {ui-setupUi(this);m_timer1 new QTimer(this);//m_timer1-setInterval(3*1000); //定时3秒connect(m_timer1, QTimer::timeout, this, MainWindow::onTimerOut1);m_timer2 new QTimer(this);//m_timer2-setInterval(5*1000); //定时5秒connect(m_timer2, QTimer::timeout, this, MainWindow::onTimerOut2); }MainWindow::~MainWindow() {delete ui; }void MainWindow::on_startPushButton1_clicked() {m_timer1-start(3*1000); //3秒定时器qDebug() 定时器1开始 QTime::currentTime().toString(hh:mm:ss); }void MainWindow::on_stopPushButton1_clicked() {m_timer1-stop();qDebug() 定时器1停止 QTime::currentTime().toString(hh:mm:ss); }void MainWindow::onTimerOut1() {qDebug() 定时器1 QTime::currentTime().toString(hh:mm:ss); }void MainWindow::on_startPushButton2_clicked() {m_timer2-start(5*1000); //5秒定时器qDebug() 定时器2开始 QTime::currentTime().toString(hh:mm:ss); }void MainWindow::on_stopPushButton2_clicked() {m_timer2-stop();qDebug() 定时器2停止 QTime::currentTime().toString(hh:mm:ss); }void MainWindow::onTimerOut2() {qDebug() 定时器2 QTime::currentTime().toString(hh:mm:ss); }运行程序点击“开始”“开始”等一会点击“停止”“停止” 输出内容如下定时器1每隔3秒输出一次定时器2每隔5秒输出一次符合程序设定
http://wiki.neutronadmin.com/news/258778/

相关文章:

  • 网站建设实训报告册建材网站开发
  • 句容网站建设开发网站建设详细过程
  • 大理做网站哪家好网站投入费用
  • 网站模板手机目前最火的互联网项目
  • 上海营销型网站建设公司网站建设 问卷调查
  • phpcmsv9网站地图西部数码网站备案核验单
  • 网站美化教程下载短网址生成免费
  • 网站模板带后台 下载360投放广告怎么收费
  • 前台网站系统源码三视觉平面设计网
  • 手机网站制作套餐福清市百度seo
  • 网站应如何设计网站为契机建设校园数字化
  • php商务网站开发代码山东展厅设计公司
  • 网站建设费用的账务处理投资5万的小型加工厂
  • 内容网站 如何做采集网站页面排名优化
  • 株洲能建网站的有哪些网站博客程序
  • 做微视频的网站wordpress添加爬虫数据
  • 2008 iis 添加 网站 权限宁远做网站
  • 如何做产品网站网页设计天津海外seo
  • 织梦可以做商城网站吗网站托管共享服务器费用一年多少钱
  • 只用php做网站哪个网站空间好
  • 2017网站设计wordpress模版做网页
  • 做搜狗手机网站优wordpress 3.5 下载
  • 微网站与移动开发是做什么的上海莱布拉网站建设
  • 建论坛网站wordpress增加小工具
  • 广西网站建设公司电话建立网站方法
  • 黄石百度做网站多少钱深圳外企公司排名
  • 广州站在哪里辽宁鞍山刚刚发布
  • 中小学网站建设方案公司网站建设和推广
  • wordpress 多站点 拷贝自己建设网站步骤
  • 陕西网站建设厦门网站制作福州做网站互联网公司