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

QLineEdit inconsistently changes layout direction when text changes

    XMLWordPrintable

Details

    • e08f6d601de4faea869dcfd05a7e133366328981 (qt/qtbase/dev) 045804c45d886af6b8d9ffba50608384c5a10d20 (qt/qtbase/6.2)

    Description

      QLineEdit tests after each key press event accepted by the control whether the layout direction of the text document has changed, and changes its own layout direction if so:

      // QLineEdit::keyPressEvent
      
          d->control->processKeyEvent(event);
          if (event->isAccepted()) {
              if (layoutDirection() != d->control->layoutDirection())
                  setLayoutDirection(d->control->layoutDirection());
              d->control->updateCursorBlinking();
          }
       }

      QLineEdit is the only widget that does that, and it does so only for key presses. It doesn't apply that logic for programmatic changes to the text, which results in an inconsistent user experience. If the QLineEdit is initialized with RTL text but without explicitly setting the layout direction, then the widget's layout direction is still Qt::LeftToRight; but the first accepted key press (cursor navigation, or appending any latin1 character) will change the layout direction to Qt::RightToLeft. Selecting all text and cutting it out via keyboard shortcuts (Ctrl+A;Ctrl+X) will change the layout direction back to LTR, but using the context menu event actions to do the same will not.

      QTextEdit does not apply any such logic, i.e. typing in an RTL language does not flip the vertical scrollbar to the left.

      This logic seems broken, and should be removed from QLineEdit as well.

      Attachments

        Issue Links

          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
              vhilshei Volker Hilsheimer
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes