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

QDoubleValidator allows to use both "C" locale and system locale

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.0.0
    • 4.7.0
    • Core: Locales (i18n)
    • None
    • Debian GNU/Linux "Squeeze" (testing) amd64, KDE 4.3.4, Qt 4.7.0-TechPreview libraries, QtCreator-1.3.81; language: russian, contry: ukraine
    • 0436281771d5d47f0c80d0694f938bb8f737da4c

    Description

      When using QDoubleValidator to validate QLineEdit input I take notice that it is possible to use both "C" locale and system locale to identificate what groupSeparator and decimalPoint can be used.

      Step by step:

      • I don't specify QLocale for QDoubleValidator, so used system locale by default
      • I'm expect for ' ' (whitespace) as groupSeparator and ',' (comma) as decimalPoint (for my Locale RU_ru)
      • When I'm run code (see below) I can use groupSeparator ',' and decimalPoint '.' (that is "C" locale) or I can use groupSeparator ' ' and decimalPoint ',' (that is my system locale) instead

      I'm assume that only system locale must be available for QDoubleValidator. Otherwise user may be confused, what means ',' (comma) - groupSeparator or decimalPoint.

      This code can help to reproduce my situation:

      main.cpp
      #include <QApplication>
      #include <QLineEdit>
      #include <QDoubleValidator>
      #include <QLocale>
      #include <QDebug>
      
      int main(int argc, char *argv[])
      {
      	QApplication app(argc, argv);
      
      	QDoubleValidator validator;
      	validator.setLocale(QLocale::system());
      
      	qDebug() <<
      			"language: " <<
      			QLocale::languageToString(validator.locale().language()) << "\n" <<
      			"country: " <<
      			QLocale::countryToString(validator.locale().country());
      
      	QLineEdit edtTest;
      	edtTest.setValidator(&validator);
      
      	edtTest.show();
      	return app.exec();
      }

      Try to enter "123,123,123.123".
      And then delete it and try to enter "123 123 123,123".

      Attachments

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

        Activity

          People

            johnlayt John Layt
            joe Sam Protsenko
            Votes:
            4 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes