Results 1 to 5 of 5

Thread: How to show Time like 12:12:01 instead of 12:12:1 ?

  1. #1
    Join Date
    Jan 2012
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    5

    Default How to show Time like 12:12:01 instead of 12:12:1 ?

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to show Time like 12:12:01 instead of 12:12:1 ?

    Yes, both QTime::toString() and QString::arg() allow precise formatting. So whichever you are using, the API is there.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2012
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    5

    Default Re: How to show Time like 12:12:01 instead of 12:12:1 ?

    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

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to show Time like 12:12:01 instead of 12:12:1 ?

    How about you show us your current code?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    33
    Thanked 10 Times in 10 Posts

    Default Re: How to show Time like 12:12:01 instead of 12:12:1 ?

    Read the documentation of QTime.. an example

    Qt Code:
    1. QTime time = QTime::currentTime ();
    2. qDebug () << time.toString ("hhmmss");
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. how to show time in a GraphicsItem
    By wagmare in forum Qt Programming
    Replies: 9
    Last Post: 24th April 2009, 10:52
  2. QAbstractItemView - Show all contents all the time...
    By youkai in forum Qt Programming
    Replies: 5
    Last Post: 31st August 2008, 17:54
  3. Show System Time Stamp ??
    By dheeraj in forum Qwt
    Replies: 3
    Last Post: 21st April 2008, 12:54
  4. Show progress of a time consuming operation
    By rainman110 in forum Newbie
    Replies: 7
    Last Post: 10th February 2008, 13:07
  5. How to show/draw focus & select at the same time
    By tanminh in forum Qt Programming
    Replies: 2
    Last Post: 6th November 2006, 22:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.