我有一个 QDateEdit
QDateEdit
我已经试过了:
self.ui.date.setLocale(QtCore.QLocale( QtCore.QLocale.English, QtCore.QLocale.UnitedStates)) self.ui.date.calendarWidget().setLocale(QtCore.QLocale( QtCore.QLocale.English, QtCore.QLocale.UnitedStates))
通过这样做,当我单击小部件时弹出的calendarWidget变为英文。但是,如果我这样做:
print ui.date.date().toString("MMMM dd, yyyy")
我仍然用葡萄牙语而不是英语。我还尝试使用python的locale模块更改区域设置,但没有产生任何结果。
使用 QLocale.toString 方法
print(QLocale(QLocale.English, QLocale.UnitedStates).toString(self.ui.date.date(), "MMMM dd, yyyy"))`
QDate是日期的独立于区域设置的表示形式。格式化时需要指定区域设置。。。