如题
离线
找到了: https://forum.qt.io/topic/74166/using-qtimer-in-main-not-in-a-class/3
#include <QApplication>
#include <QDebug>
#include <QTimer>
void someFunction()
{
qDebug() << "Some function";
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTimer timer;
QObject::connect(&timer, &QTimer::timeout, someFunction);
QObject::connect(&timer, &QTimer::timeout, []() { qDebug() << "Lambda"; });
timer.start(500);
return a.exec();
}
测试了, 可以用。
离线