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