欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Qt 计算两个日期的时间差并以时分秒显示出来

程序员文章站 2024-02-01 20:02:28
...
QDateTime begin_time = QDateTime::currentDateTime();             //获取或设置时间
QDateTime end_time = QDateTime::currentDateTime();               //获取或设置时间
QTime m_time;						
m_time.setHMS(0, 0, 0, 0);                                       //初始化数据,时 分 秒 毫秒
m_time.addSecs(begin_time.secsTo(end_time)).toString("hh:mm:ss");//计算时间差(秒),将时间差加入m_time,格式化输出