you can get data from a model in QVariant object and then you can use QVariant::toDate method.
you can get data from a model in QVariant object and then you can use QVariant::toDate method.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
Thanks for the quick answer.
Do I have to parse all the rows of the query and transform them in QDate or do it on the model?
This is the format of the field:
"25.11.2008 16:05:00"
I tried to convert the QVariant with this string into a QDateTime but it doesn't work. It gets an empty QDateTime.
Thanks
the date/time/datetime format must be ISO
another way, if you don't what to change format in databse, you can use static method of QDate -- QDate::fromString and pass needed mask as the second parametr.QDate QVariant::toDate () const
Returns the variant as a QDate if the variant has type() Date, DateTime, or String; otherwise returns an invalid date.
If the type() is String, an invalid date will be returned if the string cannot be parsed as a Qt::ISODate format date.
See also canConvert() and convert().
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
Bookmarks