How to call a function periodically in Qt?

后端 未结 5 1267
耶瑟儿~
耶瑟儿~ 2021-02-14 22:10

Is it possible to call a function periodically in C++ with Qt function ?
And how to stop the timed function after it is set to be called periodically ?

5条回答
  •  长情又很酷
    2021-02-14 23:09

    If you are using qt, you can you QTimer which by default creates a repetitive timer.

    There is an example in the documentation (shown below) and an example (Analog Clock).

    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(update()));
    timer->start(1000);
    

提交回复
热议问题