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

QValidator::changed() is not used by QLineEdit

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.12.3
    • None

    Description

      QValidator has a changed() signal to notify that its inputs have changed, implying that the validity of the text may have changed.

      However, this signal is not used by QLineEdit (QWidgetLineControl).

      auto validator = new QIntValidator();
      validator->setRange(0, 9);
      lineEdit->setValidator(validator);
      lineEdit->setText("99"); // "99" is invalid, but setText() ignores the validator
      validator->setRange(10, 99);
      // From here, the text "99" is valid: QLineEdit::hasAcceptableInput() returns true
      // However, the QLineEdit has not received the changed() signal and QWidgetLineControl::m_validInput is still false
      // This situation allows user to type anything e.g. a letter, meaning that we could end up having "99a" as text.
      

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            bterrier Benjamin Terrier
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes