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

Layout is always RTL when locale is RTL

    XMLWordPrintable

Details

    • All
    • 6b687ad7ec46fed10766f5d26809c4fe430db608 (qt/qtquickcontrols2/dev)
    • Bug Fixing Candidates

    Description

      Currently, if we set RTL locale, whole layout changes to RTL,
      and there is no way to change the layout back to LTR.

      in main.cpp, add following lines to set RTL locale.

          QLocale egyptian(QLocale::Arabic, QLocale::Egypt);
          QLocale::setDefault(egyptian);
      

      and the main.qml looks like below

      main.qml
      import QtQuick 2.12
      import QtQuick.Window 2.2
      import QtQuick.Controls 2.12
      
      Window {
          visible: true
          width: 1280
          height: 720
          title: qsTr("Hello World")
      
          ProgressBar {
      //        LayoutMirroring.enabled: false
              anchors.centerIn: parent
              indeterminate: true
          }
      }
      

      When you run the sampler above, you will find out there is no way to change layout back to LTR.

      This is because QQuickControl::isMirrored() checks layout mirroring OR text locale.
      If the locale is RTL, isMirrored() always returns true.

      https://code.qt.io/cgit/qt/qtquickcontrols2.git/tree/src/quicktemplates2/qquickcontrol.cpp#n1289

      bool QQuickControl::isMirrored() const
      {
          Q_D(const QQuickControl);
          return d->isMirrored() || d->locale.textDirection() == Qt::RightToLeft;
      }
      

      FYI. This could be resolved by reverting https://codereview.qt-project.org/c/qt/qtquickcontrols2/+/143100

      Attachments

        Issue Links

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

          Activity

            People

              hyunkook_khang Hyunkook Khang
              hyunkook_khang Hyunkook Khang
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes