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

QDoubleValidator unexpected behaviour using different locale

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Fixed
    • Affects Version/s: 5.14.1
    • Fix Version/s: None
    • Component/s: Core: Locales (i18n)
    • Labels:
      None
    • Platform/s:
      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

          For Gerrit Dashboard: QTBUG-90719
          # Subject Branch Project Status CR V

            Activity

              People

              Assignee:
              ivan.solovev Ivan Solovev
              Reporter:
              qt-knut Knut Beese
              PM Owner:
              Vladimir Minenko Vladimir Minenko
              RnD Owner:
              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