0

I have a QDateEdit object (field on a display window). When I use the only real option (according to the PySide site) QDateEdit.date() I get "2000, 1, 1" instead of "1/1/2000" and the documentation is completely useless for telling what to do with this data to use it as a real date. "2000, 1, 1" isn't a real date.

How to make this a date I can actually use and why I can't use any of the attributes described on the PySide site under QDate, QDateEdit, or QDateTimeEdit?

2

1 Answer 1

1

I am having a hard time trying to determine what you mean by "real date", but here is my idea of what you could want:

# QDateEdit's .date() returns a QtCore.QDate object
date = QtCore.QDate(2013, 1, 1)

# Get the string in whatever format you want
date.toString("MM/dd/yyyy")
Out[10]: u'01/01/2013'

# Get the date as a datetime object
date.toPython()
Out[11]: datetime.date(2013, 1, 1)

I got all of this from the PySide wiki

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.