Eduardo Eduardo - 2 years ago 90
Python Question"MMMM dd, yyyy") does not display months in English

I have a

which is called date. No matter what I do, I'm not able to make it display the months in English, it always displays them in my current locale.

I've already tried:
QtCore.QLocale.English, QtCore.QLocale.UnitedStates))
QtCore.QLocale.English, QtCore.QLocale.UnitedStates))

By doing this, the calendarWidget that pops-up when I click the widget changed to English. However, if I do:

print"MMMM dd, yyyy")

I still get the months in Portuguese instead of English. I also tried to change the locale with python's locale module but it didn't yield any results.

Answer Source

Use QLocale.toString method


print(QLocale(QLocale.English, QLocale.UnitedStates).toString(, "MMMM dd, yyyy"))`

QDate is a locale independent representation of the date. You need to specify the locale when formatting ...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download