Results 1 to 3 of 3

Thread: QTime not displaying properly in Qt 5.9

  1. #1
    Join Date
    Mar 2014
    Location
    USA
    Posts
    84
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default QTime not displaying properly in Qt 5.9

    I'm using a QTime in Qt 5.9 to hold an elapsed time. Got that part. When I go to display it as a string with time.toString("hh:mm:ss.zzz") it drops the hours. According to the documentation (they explicitly give that format as an example) that's the proper format. Am I doing something wrong or is it a bug in 5.9? I tried a few different foramts (":hh:mm:ss.zzz", ".hh:mm:ss.zzz", and "hh:mm:ss:zzz") and those formats display as written, but that's not what they want, they want hh:mm:ss.zzz.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,643
    Thanks
    256
    Thanked 738 Times in 728 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: QTime not displaying properly in Qt 5.9

    What happens if you use the alternate form of QTime::toString() with the Qt::ISODateWithMs argument?

    Even if this doesn't work, you can always write your own formatting using QString::arg() features. All of the fields you need are accessible as QTime methods.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    TonyInSoMD (3rd August 2020)

  4. #3
    Join Date
    Mar 2014
    Location
    USA
    Posts
    84
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QTime not displaying properly in Qt 5.9

    I'll try that and see if it works, if not I can always QString::arg(). Thanks for the idea, it didn't even occur to me.

Similar Threads

  1. QTime
    By dragon in forum Newbie
    Replies: 12
    Last Post: 16th February 2012, 10:40
  2. Help me qtime in qt?
    By tamnv110 in forum Newbie
    Replies: 7
    Last Post: 16th June 2011, 11:59
  3. Replies: 2
    Last Post: 8th February 2011, 14:15
  4. Replies: 0
    Last Post: 13th August 2010, 12:17
  5. QTime
    By bismitapadhy in forum Qt Programming
    Replies: 1
    Last Post: 26th June 2009, 05:21

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.