想精度高,可以考虑用c语言中的函数gettimeofday

时间:2023-03-09 21:23:26
想精度高,可以考虑用c语言中的函数gettimeofday

大家好:
在 win32 + bcb 时, 有个 GetTickCount() 返回第统启动到现在的 tick, 单位 ms.
请问在 Linux + qt5 怎样实现呢? 如果用 QDateTime , 精度只能到秒,而且运行过程中,如果
用户改充了系统时间,就会出错了。

用QElapsedTimer。

想精度高,可以考虑用c语言中的函数gettimeofday,微秒级精度

#include <sys/time.h>
int gettimeofday(struct timeval*tv, struct timezone *tz);

http://www.qtcn.org/bbs/read-htm-tid-61246.html