uint64_t vcs_timer::get_usec()
{
static qint64 usec = 0;
static qint64 temp_usec = 0;
QDateTime time1 = QDateTime::currentDateTime();
qint64 msec_now1 = time1.currentMSecsSinceEpoch();
msec_now1 %= 10000;
if(temp_usec > msec_now1)usec+=10000;
temp_usec =msec_now1;
return (usec + temp_usec);
}
void vcs_timer::run()
QT C++毫秒级定时器实现与追述功能

本文介绍了如何在Windows系统下使用C++和QT库创建一个自定义的毫秒级时钟,并实现追述功能。由于Windows系统内置的30ms以下定时器精度不足,作者提供了一种解决方案来确保定时器能够精确到毫秒单位。
最低0.47元/天 解锁文章
1461

被折叠的 条评论
为什么被折叠?



