------------------------------------------------------------
author: hjjdebug
date: 2024年 08月 25日 星期日 09:58:23 CST
description: qtimer 测试研究
------------------------------------------------------------
测试代码:
hjj@hjj-7090:~/test/qtimer$ cat main.cpp
#include <QApplication>
#include "mytimer.h"
int main(int argc, char *argv[])
{
QApplication app(argc,argv);
MyTimer *timer= new MyTimer();
timer->start();
return app.exec();
}
hjj@hjj-7090:~/test/qtimer$ cat mytimer.h
#ifndef _MY_TIMER_H
#define _MY_TIMER_H
#include <QTimer>
class MyTimer : public QObject
{
Q_OBJECT
public:
MyTimer();
~MyTimer();
void start();
public slots:
void slotTimerout();
private:
QTimer * m_timer=NULL;
};
#endif
hjj@hjj-7090:~/test/qtimer$ cat mytimer.cpp
#include "mytimer.h"
#include <stdio.h>
MyTimer::MyTimer()
{
m_timer = new QTimer();
m_timer->setSingleShot(true)