How to give a delay in loop execution using Qt

前端 未结 4 995
北海茫月
北海茫月 2020-12-09 02:26

In my application I want that when a loop is being executed, each time the control transfers to the loop, each execution must be delayed by a particular time. How can I do t

4条回答
  •  我在风中等你
    2020-12-09 03:01

    As an update of @Live's answer, for Qt ≥ 5.2 there is no more need to subclass QThread, as now the sleep functions are public:

    Static Public Members

    • QThread * currentThread()
    • Qt::HANDLE currentThreadId()
    • int idealThreadCount()
    • void msleep(unsigned long msecs)
    • void sleep(unsigned long secs)
    • void usleep(unsigned long usecs)
    • void yieldCurrentThread()

    cf http://qt-project.org/doc/qt-5/qthread.html#static-public-members

提交回复
热议问题