QT計算時間戳差值


方法一:(還未嘗試)
QTime startTime = QTime::currentTime(); QThread::msleep(SLEEP_TIME_MILL); QTime stopTime = QTime::currentTime(); int elapsed = startTime.msecsTo(stopTime); qDebug()<<"QTime.currentTime ="<<elapsed<<"ms";

方法二:

 QDateTime current _time = QDateTime::currentDateTime();

//計算時間差,先將兩時間值 轉成uint型,再進行減操作

  uint start_time = time.toTime_t();   //time在之間就獲取了

     uint end_time = current_tome.toTime_t();

   int t_Ret = end_time - start_time;//計算結果為s
 
        

 

 
         
         
       


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM