How do I create a pause/wait function using Qt?

后端 未结 12 2237
执笔经年
执笔经年 2020-11-27 15:19

I\'m playing around with Qt, and I want to create a simple pause between two commands. However it won\'t seem to let me use Sleep(int mili);, and I can\'t find

12条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 16:03

    Small +1 to kshark27's answer to make it dynamic:

    #include 
    
    void delay( int millisecondsToWait )
    {
        QTime dieTime = QTime::currentTime().addMSecs( millisecondsToWait );
        while( QTime::currentTime() < dieTime )
        {
            QCoreApplication::processEvents( QEventLoop::AllEvents, 100 );
        }
    }
    

提交回复
热议问题