Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-92112

QDateEdit popup calendar widget adds a comma to the year value when the year has been edited using the calendar widget

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Fixed
    • Affects Version/s: 5.15.0
    • Fix Version/s: 5.15.2
    • Labels:
      None
    • Environment:
      Default en-US locale
    • Platform/s:
      Linux/X11, macOS, Windows
    • Commits:
      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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              Assignee:
              qt.team.quick.subscriptions Qt Quick and Widgets Team
              Reporter:
              nikel Nik Twerdochlib
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes