Qt documentation about QTime::currentTime()
says :
Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.
But is there any way to get this time with milliseconds accuracy in windows 7?
Show activity on this post. Create a QTimer with 1 sec interval (or e.g. 100 msec for more accuracy), connect its timeout signal to your slot. In the slot get the current time using QTime::currentTime() static function, convert it to string using toString and assign it to a GUI element (e.g. a label).
[static] QDateTime QDateTime::currentDateTimeUtc() Returns the current datetime, as reported by the system clock, in UTC. See also currentDateTime(), QDate::currentDate(), QTime::currentTime(), and toTimeSpec().
You can't stop QElapsedTimer , because there is no timer. When you call method start() , QElapsedTimer saves the current time. When elapsed, it gets current time again, and calculate difference.
you can use the functionality provided by time.h header file in C/C++.
#include <time.h>
clock_t start, end;
double cpu_time_used;
int main()
{
start = clock();
/* Do the work. */
end = clock();
cpu_time_used = ((double)(end-start)/ CLOCKS_PER_SEC);
}
You can use QDateTime
class and convert the current time with the appropriate format:
QDateTime::currentDateTime().toString("yyyy/MM/dd hh:mm:ss,zzz")
where 'z' corresponds to miliseconds accuracy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With