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

Text in Combo Box does not follow RTL layout direction when mixing RTL and LTR text

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.4.1, 6.8.0
    • GUI: Font handling
    • None

    Description

      Repo steps:
      1. Create a combo box whose elements in the drop down list mix RTL text and LTR text (I inserted English letters in between Arabic or Hebrew words)
      2. Set the layout direction to RightToLeft

      Expected Behaviour:
      All text in both the drop down list and the main selection follows RTL layout direction

      Actual Behaviour:
      The text in the drop down list behaves as expected; the text in the main entry is laid out LeftToRight.

      For example, if in c++ I add an entry to a combo box with a string of the form
      "A " + "[some arabic text 1]" + " B " + "[some arabic text 2]" + " C"

      I would expect, since the layout direction is RightToLeft, to see in the combo box:
      "C " + "[some arabic text 2]" + " B " + ""[some arabic text 1]" + " A"

      The above is how it is laid out in the drop down list. However, in the main selection, the text appears as I entered it, without it being laid out RightToLeft:
      "A " + "[some arabic text 1]" + " B " + "[some arabic text 2]" + " C"

      For this example, see "Arabic RTL 8" or "Hebrew RTL 8"; notice how the last entry in the drop down box is different from the main selection, even though they are the same string.

      This also happens regardless of whether the RTL or LTR text starts; see "Arabic RTL 5" where the string is
      "[some arabic text 1]" + " A " + "[some arabic text 2]"

      And in the drop down list, it was correctly displayed as
      "[some arabic text 2]" + " A " + "[some arabic text 1]"

      But when in the main selection area it displayed as
      "[some arabic text 1]" + " A " + "[some arabic text 2]"

      Note that if there is no mixing of English and Arabic characters (or any other RTL and LTR text) the behaviour works as expected. See "Arabic RTL 1" for an all RTL example (where both the drop down and main selection match) and "French RTL 1" for an all LTR text example with the layout direction still being RightToLeft; note again that the drop down and main selection match.

      Code update:
      I just created a new project and only inserted a QComboBox named comboBox. Then I added these lines in the MainWindow::MainWindow function after ui->setupUi(this);

      setLayoutDirection(Qt::RightToLeft);
      ui->comboBox->addItem(QString(" في ") + QString(" لطيف "));
      ui->comboBox->addItem(QString("A ") + QString(" في ") + QString(" لطيف "));
      ui->comboBox->addItem(QString("في") + QString(" A ") + QString("لطيف"));
      ui->comboBox->addItem(QString(" في ") + QString(" لطيف ") + QString(" A"));
      ui->comboBox->addItem(QString("A ") + QString("في") + QString(" B ") + QString("لطيف"));
      ui->comboBox->addItem(QString(" في ") + QString(" A ") + QString("لطيف") + QString(" B"));
      ui->comboBox->addItem(QString("A ") + QString("في") + QString(" لطيف ") + QString(" B"));
      ui->comboBox->addItem(QString("A ") + QString("في") + QString(" B ") + QString("لطيف") + QString(" C"));

      See "Update Arabic RTL" for an image of what the result was.

      Attachments

        1. Arabic RTL 1.png
          Arabic RTL 1.png
          18 kB
        2. Arabic RTL 2.png
          Arabic RTL 2.png
          18 kB
        3. Arabic RTL 3.png
          Arabic RTL 3.png
          18 kB
        4. Arabic RTL 4.png
          Arabic RTL 4.png
          18 kB
        5. Arabic RTL 5.png
          Arabic RTL 5.png
          18 kB
        6. Arabic RTL 6.png
          Arabic RTL 6.png
          19 kB
        7. Arabic RTL 7.png
          Arabic RTL 7.png
          19 kB
        8. Arabic RTL 8.png
          Arabic RTL 8.png
          19 kB
        9. French RTL 8.png
          French RTL 8.png
          20 kB
        10. Hebrew RTL 8.png
          Hebrew RTL 8.png
          24 kB
        11. UPDATE Arabic RTL.png
          UPDATE Arabic RTL.png
          31 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            mnyhus Matthew Nyhus
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes