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

[REG 5.9.9->5.12.6] QIntValidator and QLineEdit allow to enter positive value which is greater than specified maximum

    XMLWordPrintable

Details

    • macOS, Windows
    • 5c1bc5c8a41e9d4b40161eae1413bcb69325dd8f (qt/qtbase/5.15)
    • Q1/2020 Finale, Q2/2020 kick off

    Description

      QIntValidator and QLineEdit allow to enter positive value which is greater than specified maximum.

      Example code (see also the attached file):

      #include <QApplication>
      #include <QLineEdit>
      #include <QWidget>
      #include <QIntValidator>
      
      #include <QApplication>
      #include <QLineEdit>
      #include <QWidget>
      #include <QIntValidator>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QWidget w;
          w.resize(100, 100);
      
          int maxValue = 15;
          QIntValidator* iv = new QIntValidator(0, maxValue, &w);
      
          QLineEdit* lineEdit = new QLineEdit(&w);
          lineEdit->setGeometry(QRect(20, 40, 60, 20));
      
          lineEdit->setValidator(iv);
      
          w.show();
      
          return a.exec();
      }
      

      In this code the maximum is set to 15. In this case:

      • Using Qt 5.12.6 or Qt 5.12.7 I can enter any two-digit number which is greater than 15 (for example 25 or 38). It is an unexpected behavior.
      • Using Qt 5.9.9 I cannot enter a number greater than 15. It is an expected behavior.

      Attachments

        1. main.cpp
          0.5 kB
          Dzmitry Tsurko

        Issue Links

          Activity

            People

              vhilshei Volker Hilsheimer
              tsurko.dmitry Dzmitry Tsurko
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: