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

QLineEdit::setSelection bug when inputMask is used

    XMLWordPrintable

Details

    • 7266e11297874736e54bc59fd3d4d827d03ce2e2

    Description

      When an inputMask is used with a QLineEdit, setSelection might fail.
      See small sample application: the last character should be selected, but it is not.

      The bug is easy to locate. In QLineEdit::setSelection, the code starts with:

      if (start < 0 || start > (int)d->control->text().length())

      { qWarning("QLineEdit::setSelection: Invalid start position (%d)", start); return; }

      But it is wrong to use d->control->text() because this removes the blank characters when an input mask is used. This causes a wrong warning to be issue and a return.

      The code should be in fact:

      if (start < 0 || start >= (int)d->control->end()) {

      Attachments

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

        Activity

          People

            andysh Andy Shaw
            jirauser26727 user-04d21 (Inactive)
            Votes:
            4 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes