PDA

View Full Version : System Current time



anh5kor
13th February 2015, 07:00
Hello

In my code I have to get system time and then add second to it and display in gui
suppose I got system_time = 10:30:40
second (from my code)= 40
display = system_time+second;i.e 10:31:20
I have added a code


unsigned int Time_second_ecu2uss;
QTime time = QTime::currentTime();
QString timeString = time.toString();
Time_second_ecu2uss = Time_ecu2uss/1000;(getting the second)
qDebug()<<"timeString"<<timeString + Time_second_ecu2uss;


but my output is timeString "10:31:20t"

anda_skoa
13th February 2015, 07:52
You are appending an integer to a string, that doesn't change the string.
If you want to add seconds to a time object, use QTime::addSecs().

Cheers,
_

anh5kor
13th February 2015, 08:34
Thanks for information