Results 1 to 5 of 5

Thread: QTime and QDate from String

  1. #1
    Join Date
    Feb 2014
    Posts
    7
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default QTime and QDate from String

    I have QString keeps dates like 2014-11-23 06:55:59
    I want to parse this QString to QDate and QTime.

    I've tried
    Qt Code:
    1. QDate myDate;
    2. myDate = QDate::fromString(qStr,"yyyy-MM-dd HH:mm:ss");
    To copy to clipboard, switch view to plain text mode 

    When i debug the code, i see QString value correctly, but mydate has no value. How can i fix it?
    Last edited by Eleasar; 11th February 2014 at 12:13.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTime and QDate from String

    Because time is not a part of date ? Try this :
    Qt Code:
    1. QDate myDate = QDateTime::fromString(qStr,"yyyy-MM-dd HH:mm:ss").date();
    To copy to clipboard, switch view to plain text mode 

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

    Eleasar (11th February 2014)

  4. #3
    Join Date
    Feb 2014
    Posts
    7
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QTime and QDate from String

    Done, Thank you

  5. #4
    Join Date
    May 2014
    Posts
    1
    Qt products
    Qt5

    Default Re: QTime and QDate from String

    hi everyone,
    i have been coding hotel management system and i would like to do something like this. in one lineedit it will be written check-in date which ı can do it and when i will write number of nights program will write automatically check-out date. i am waiting for your help.
    thank you

  6. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QTime and QDate from String


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. QTime
    By bismitapadhy in forum Qt Programming
    Replies: 1
    Last Post: 26th June 2009, 05:21
  4. Getting QDate from string
    By yagabey in forum Qt Programming
    Replies: 10
    Last Post: 17th February 2009, 15:40
  5. Extending QDate, QTime and QDateTime
    By jamadagni in forum Qt Programming
    Replies: 8
    Last Post: 24th March 2006, 15:51

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.