QObject
最后更新于:2022-04-02 02:15:36
[TOC]
## QObject
## 常用函数
## startTimer
通过 startTimer 触发 timerEvent, 每个n时刻,触发
```
class MyObject : public QObject
{
Q_OBJECT
public:
MyObject(QObject *parent = 0);
protected:
void timerEvent(QTimerEvent *event);
};
MyObject::MyObject(QObject *parent)
: QObject(parent)
{
startTimer(50); // 每个50毫秒出发一次 timerEvent
}
void MyObject::timerEvent(QTimerEvent *event)
{
qDebug() << "Timer ID:" << event->timerId();
}
```
';