Exemplo:
myscheduler.h
#ifndef EMAILSCHEDULER_H
#define EMAILSCHEDULER_H
#include <QSqlDatabase>
#include <TGlobal>
#include <QObject>
#include <TApplicationScheduler>
class T_HELPER_EXPORT MyScheduler : public TApplicationScheduler
{
Q_OBJECT
public:
MyScheduler(QObject *parent = nullptr);
~MyScheduler();
protected:
void job();
signals:
};
#endif // EMAILSCHEDULER_H
myscheduler.cpp#include "myscheduler.h"MyScheduler::MyScheduler(QObject *parent) : TApplicationScheduler(parent){}MyScheduler::~MyScheduler(){}void EmailScheduler::job(){tDebug() << "execute your job";}
Para iniciar. O timer vai ser executado a cada 2 segundos.
MyScheduler *scheduler = new MyScheduler(0);
int msec = 2000;scheduler->start(time);