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

Readonly QLineEdit emits editingFinished on focus lost

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 5.11.3
    • None
    • All

      Hi there,

      just noticed an interesting behavior. When a QLineEdit is set to readonly, and it is focused and looses focus again, the editingFinished() signal is emitted. This is somewhat unexpected, since "readonly" means there won't be any editing, right?

      The relevant code is in qlineedit.cpp:1895 (in Qt 5.11.3):
      Qt Code:

      if (reason != Qt::PopupFocusReason
              || !(QApplication::activePopupWidget() && QApplication::activePopupWidget()->parentWidget() == this)) {
                  if (hasAcceptableInput() || d->control->fixup())
                      emit editingFinished();
          }
      

      The signal is emitted without checking the "readonly" state. 

       

      Haven't checked, but probably applies to newer Qt versions as well.

        1. qtbug77728.tar.xz
          0.9 kB
          Joerg Bornemann
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            andreas Andreas Nicolai
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes