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

QDoubleValidator unexpected behaviour using different locale

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • None
    • 5.14.1
    • Core: Locales (i18n)
    • None
    • Windows

    Description

      Using QDoubleValidator on german system leads to unexpected results on validate(). It seems that thousand-seperator is forced to be present. If not present input is handled as Invalid.

          QDoubleValidator validator;
          validator.setNotation( QDoubleValidator::StandardNotation);
      
          int pos;
          QString str("-0.3");
          QValidator::State valid;
      
          validator.setLocale( QLocale::C);
          validator.setRange(-3.0, 0.0);
          valid = validator.validate( str, pos);      // returns Invalid
          validator.setRange(-2.99, 0.0);
          valid = validator.validate( str, pos);      // returns Invalid
      
          validator.setLocale( QLocale::German);
          validator.setRange(-3.0, 0.0);
          valid = validator.validate( str, pos);      // returns Acceptable (str converted to -3 ?)
          validator.setRange(-2.99, 0.0);
          valid = validator.validate( str, pos);      // returns Intermediate
      
          str = "-0,3";
      
          validator.setLocale( QLocale::C);
          validator.setRange(-3.0, 0.0);
          valid = validator.validate( str, pos);      // returns Acceptable (str converted to -3 ?)
          validator.setRange(-2.99, 0.0);
          valid = validator.validate( str, pos);      // returns Intermediate
      
          validator.setLocale( QLocale::German);
          validator.setRange(-3.0, 0.0);
          valid = validator.validate( str, pos);      // returns Invalid
          validator.setRange(-2.99, 0.0);
          valid = validator.validate( str, pos);      // returns Invalid
      
      

       

       

      Attachments

        Issue Links

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

          Activity

            People

              ivan.solovev Ivan Solovev
              qt-knut Knut Beese
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes