c++qtqt5qdatetime

Qt 5.2.1: cannot parse date/time


I am having a problem in parsing a date from QString using Qt 5.2.1...

I am using the following code:

QString value = "1979-10-27T04:00:00.000";
QDateTime dt = QDateTime::fromString(value, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'zzz");

but the returned QDateTime is invalid... what am I doing wrong?


Solution

  • This is likely due to the following bug in Creator:

    GDB pretty printer for QDateTime is broken, shows “(invalid)” even when QDateTime is not invalid

    According to the latest comment (01/Apr/14), it now displays a valid date until it's expanded:

    It looks much better now. QDateTime shows a human-readable format. Only when I try to expand it, it becomes "not accessible".

    I'd recommend upgrading your version of Creator.

    With as many users as Qt has, you'll often find existing bug reports for your problem if you have a quick search through Jira.