I have method. This method have static QTime but I want to reset this value if something is happened.
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 ;
}
Use the QTime::restart()
method to reset your timer.
Also, take a look at QElapsedTimer
class. It has a similar API (elapsed()
, restart()
, etc.), however you may find it more suitable for your situation. From the docs:
QElapsedTimer
will use the platform's monotonic reference clock in all platforms that support it. This has the added benefit thatQElapsedTimer
is immune to time adjustments, such as the user correcting the time. Also unlikeQTime
,QElapsedTimer
is immune to changes in the timezone settings, such as daylight-saving periods.