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

QDoubleValidator accepts numbers with thousand-separators despite the docs says it doesn't.

    XMLWordPrintable

Details

    • 94e40c7c7874a2bceb9d6f01947c1668fd92f559 (qtbase/5.4, 20.11.2014, 5.4.1)

    Description

      Please check the code bellow!
      The expected result it should be, that is invalid instead of acceptable.
      The documentation of 5.x doesn't contain: "QDoubleValidator will not accept numbers with thousand-separators." anymore.

      #include <QString>
      #include <QLocale>
      #include <QApplication>
      #include <QDoubleValidator>
      #include <QDebug>
      
      int main( int argc, char* argv[] )
      {
        QApplication a( argc, argv );
      
        QString input = "1.000.000,50";
        int pos = input.length()-1;
        QObject o; // dummy
        QDoubleValidator v( &o );
        QLocale loc(QLocale::German,QLocale::Germany);
        //loc.setNumberOptions(QLocale::RejectGroupSeparator);
        v.setLocale(loc);
        qDebug()<<"Decimal :"<<v.locale().decimalPoint();
        qDebug()<<"Group separator :"<<v.locale().groupSeparator();
        QValidator::State s = v.validate( input, pos );
        qDebug()<< "Validator result: ";
        switch ( s )
          {
          case QValidator::Invalid:
            qDebug()<<"Invalid";
            break;
          case QValidator::Intermediate:
            qDebug()<<"Intermediate";
            break;
          case QValidator::Acceptable:
            qDebug()<<"Acceptable";
            break;
          }
        return 0;
      }
      

      Attachments

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

        Activity

          People

            kleint Friedemann Kleint
            qtcomsupport Qt Support
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes