延时程序执行Qt

有时候为了让程序暂停一下,不让它一直跑下去,可以使它进入循环结构中!

例如:

#include <QCoreApplication>
#include <qdebug.h>
#include <QTime>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QTime time = QTime::currentTime();
    while(QTime::currentTime().second() - time.second() <= 10)//延时10秒钟
    {
       // qDebug()<<QTime::currentTime().second() - time.second();
    }
    qDebug()<<"已延时";

    return a.exec();
}



原文地址:https://www.cnblogs.com/lzh-Linux/p/3792626.html