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

Changing locale of a QDateEdit does not affect its popup calendar widget

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.9.0 Beta 2
    • 5.6.2, 5.7.1, 5.8.0, 5.9.0 Alpha
    • None
    • Kubuntu 16.10, Windows 10
    • e5c0371d18e285d7849cbd0569970e209bd01b49

    Description

      Changing locale settings for a widget of type QDateEdit or QDateTimeEdit is not propagated to its child widgets, specifically QCalendarWidget.

      I believe this is not the expected behavior.

      Minimum test case is attached.

      #include <QApplication>
      #include <QDialog>
      #include <QDateEdit>
      #include <QCalendarWidget>
      #include <QVBoxLayout>
      #include <QDebug>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QLocale::setDefault(QLocale(QLocale::Persian, QLocale::Iran));
          QDialog d;
          QVBoxLayout layout(&d);
          // Persian Locale
          QDateEdit dateEdit(&d);
          layout.addWidget(&dateEdit);
          dateEdit.setLocale(QLocale(QLocale::English, QLocale::UnitedKingdom));
          dateEdit.setCalendarPopup(true);
          // Or maybe set locale after enabling popup calendar. Same as previous case
          // de.setLocale(QLocale(QLocale::English, QLocale::UnitedKingdom));
          dateEdit.setDisplayFormat("yyyy-MM-dd");
          dateEdit.setDate(QDate::currentDate());
          //
          d.show();
          /*
           * Now `dateEdit' shows a date in English (line edit),
           * and a popup calendar in Persian
           */
          return a.exec();
      }
      

      Attachments

        1. terrible.png
          terrible.png
          152 kB
        2. screenshot-1.png
          screenshot-1.png
          120 kB
        3. QTBUG-dateedit.tar.gz
          0.7 kB
        For Gerrit Dashboard: QTBUG-59106
        # Subject Branch Project Status CR V

        Activity

          People

            peppe Giuseppe D'Angelo
            soroush Soroush Rabiei
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes