sergiofil
28th April 2011, 16:03
Hi, i''m workin with QDateTime and it's happen the following problem:
in mainwindow.h, i put:
QDateTime globalTime;
in mainwindow.cpp, in constructor:
globalTime.setTime(QTime(0,0));
qDebug() << "Time: " << globalTime.toString("mm:ss:zzz") << ";";
----> this debug print: Time: "" ;
I have a timer, that count to 50 ms and do:
globalTime = globalTime.addMSecs(50);
qDebug() << "Time: " << globalTime.toString("mm:ss:zzz") << ";";
------> In this debug, i get:
Time: "" ;
Time: "" ;
(...)
Time: "" ;
Time: "" ;
Time: "00:01:200" ;
Time: "00:01:250" ;
Time: "00:01:300" ;
Time: "00:01:350" ;
Time: "00:01:400" ;
(...)
-----------------------------------------------------------------------------------------------
If in constructor, i switch globalTime.setTime(QTime(0,0)); to globalTime.setTime_t(0); ,
the qDebug() << "Time: " << globalTime.toString("mm:ss:zzz") << ";";
print: Time: "00:00:000" ; and every 50ms i get the time.
So, i would like understand why the first way only show the time after 1:200 seconds.
Bye, Sérgio Silva
in mainwindow.h, i put:
QDateTime globalTime;
in mainwindow.cpp, in constructor:
globalTime.setTime(QTime(0,0));
qDebug() << "Time: " << globalTime.toString("mm:ss:zzz") << ";";
----> this debug print: Time: "" ;
I have a timer, that count to 50 ms and do:
globalTime = globalTime.addMSecs(50);
qDebug() << "Time: " << globalTime.toString("mm:ss:zzz") << ";";
------> In this debug, i get:
Time: "" ;
Time: "" ;
(...)
Time: "" ;
Time: "" ;
Time: "00:01:200" ;
Time: "00:01:250" ;
Time: "00:01:300" ;
Time: "00:01:350" ;
Time: "00:01:400" ;
(...)
-----------------------------------------------------------------------------------------------
If in constructor, i switch globalTime.setTime(QTime(0,0)); to globalTime.setTime_t(0); ,
the qDebug() << "Time: " << globalTime.toString("mm:ss:zzz") << ";";
print: Time: "00:00:000" ; and every 50ms i get the time.
So, i would like understand why the first way only show the time after 1:200 seconds.
Bye, Sérgio Silva