Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
5.15.0
-
None
-
Default en-US locale
-
-
e655f9ce987e44484c94c20f404ca629d60d7686
Description
When using a QDateEdit widget with calendarPopup set to true, if the year is changed using the QCalendarWidget (once the popup is activated) adds a comma "," to the year. It appears that when the title area of the control is updated the year is treated as a 4 digit number that is formatted based on the current locale group seperator.
Examples:
Mac
Linux
Windows
It seems that the following does provide a workaround:
QDateEdit* dateEdit = new QDateEdit;
auto calendarWidget = dateEdit->calendarWidget();
auto locale = calendarWidget->locale();
locale.setNumberOptions(locale.numberOptions() | QLocale::NumberOption::OmitGroupSeperator);
calendarWidget->setLocale(locale);
From the QtDocs for QLocale:
QLocale::OmitGroupSeparator | 0x01 | If this option is set, the number-to-string functions will not insert group separators in their return values. The default is to insert group separators. |
It does appear from a quick review of the Qt code that QLocale::toString() is used quite often in QCalendarWidget.
I was able to reproduce this behavior using the calendar widget example (https://code.qt.io/cgit/qt/qtbase.git/tree/examples/widgets/widgets/calendarwidget?h=5.15) by modifying Window::createDatesGroupBox() and calling the setCalendarPopup(true) for the minimumDateEdit, currentDateEdit, and maximumDateEdit widgets. Then running the example application, activating one of the 3 calendar popups and changing the year.
Attachments
Issue Links
- duplicates
-
QTBUG-85966 QCalendarWidget incorrecty localizes year in topbar
- Closed
-
QTBUG-86307 Year appears wrong in the Calendar Widget example
- Closed