我有办法。这个方法有静态的QTime,但是如果发生了什么事情,我想要重置这个值。
static QTime time(QTime::currentTime());
// calculate two new data points:
double key = time.elapsed()/1000;
static double lastPointKey = 0;
if(newPlot == true){
// like tihs key = 0 ;
// lastPointKey = 0 ;
}发布于 2017-02-17 13:34:27
使用QTime::restart()方法重置计时器。
另外,请看一下QElapsedTimer类。它有一个类似的API (elapsed()、restart()等),但是您可能会发现它更适合您的情况。从医生那里:
QElapsedTimer将在所有支持它的平台上使用该平台的单调参考时钟。这有一个额外的好处,即QElapsedTimer不受时间调整的影响,例如用户纠正时间。与QTime不同的是,QElapsedTimer不受时区设置变化的影响,比如夏令时。
https://stackoverflow.com/questions/42298740
复制相似问题