The fromString
method of QDate
will do the conversion for you:
myPythonicDate='2014-04-17'
qtDate = QtCore.QDate.fromString(myPythonicDate, 'yyyy-MM-dd')
print qtDate.year(), qtDate.month(), qtDate.day()
2014 4 17
yyyy-MM-dd
is the format of your date; yyyy
indicates a four digit year while MM
and dd
indicate month/date are two characters. See the fromString
documentation for a list of additional field options.