PDA

View Full Version : How to show Time like 12:12:01 instead of 12:12:1 ?



Terreox
8th February 2012, 20:18
Hi there
i would like to let my program show the current time like in the topic.
I have one QTimer and every 1000ms it calls a slot which updates one label with the current system time.
How can i let my program show a time like 12:12:01 instead of 12:12:1? is there a kind of format function?

Greetz

wysota
8th February 2012, 21:09
Yes, both QTime::toString() and QString::arg() allow precise formatting. So whichever you are using, the API is there.

Terreox
8th February 2012, 22:09
ok thanks for your hint but i dont know exactly how to use it :(
Can you please give me another hint or show me some code about it? would be nice

wysota
9th February 2012, 01:45
How about you show us your current code?

KillGabio
9th February 2012, 04:02
Read the documentation of QTime.. an example



QTime time = QTime::currentTime ();
qDebug () << time.toString ("hhmmss");