Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Itemviews and rtl languages
QtWS25 Last Chance

Itemviews and rtl languages

Scheduled Pinned Locked Moved General and Desktop
12 Posts 5 Posters 6.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    phedlund
    wrote on last edited by
    #1

    Hi all,

    I have a problem with displaying rtl languages (mainly Arabic) in a QTableView. No matter what I do the text in a cell is always displayed left aligned. When going into edit mode the QLineEdit displays the text right aligned as expected.

    I use a subclassed item delegate. In it I use QPainter::drawText. In the documentation it says that using the version of drawText that takes QRect as a parameter should handle rtl automatically, but it doesn't.

    Pasting Arabic text into any of the demo applications that use item views (e.g. the address book and frozen column samples) show the same in my opinion incorrect behavior.

    Any ideas?

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      have you something like "this":http://developer.qt.nokia.com/faq/answer/how_can_i_align_the_text_and_icons_in_an_itemview

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        There is a Qt::TextAlignmentRole in "enum Qt::ItemDataRole":http://doc.qt.nokia.com/latest/qt.html#ItemDataRole-enum. You can use this to store the alignment in your model or item (depending on wether you use the item views or item widgets)

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • P Offline
          P Offline
          phedlund
          wrote on last edited by
          #4

          Yes, sure I can specify an alignment. But my impression of the Qt documentation is that these things should be handled automatically. The linedit certainly knows without me telling it. Why doesn't the table itself? Or the QPainter::drawText()? Run the Qt address book demo and start adding some entries. Do you not expect Arabic to be right aligned when later browsing the entries? Or edit a cell in the frozen column demo with some Hebrew. When you hit enter shouldn't the cell also display the text right aligned like the editor did?

          From http://doc.qt.nokia.com/4.7/internationalization.html (my emphasis):

          QPainter::drawText(int x, int y, const QString &str) will always draw the string with its left edge at the position specified with the x, y parameters. This will usually give you left aligned strings. Arabic and Hebrew application strings are usually right aligned, so for these languages use the version of drawText() that takes a QRect since this will align in accordance with the language.

          1 Reply Last reply
          0
          • X Offline
            X Offline
            xsacha
            wrote on last edited by
            #5

            What should the itemview do in the case that there is both arabic and english items?

            • Sacha
            1 Reply Last reply
            0
            • T Offline
              T Offline
              tobias.hunger
              wrote on last edited by
              #6

              xsacha: The same as two line edits do, one with english the other with arabic text? If you have a item with both arabic and english text then it should do what a lineedit does with the same text.

              How to mix left-to-right and right-to-left languages is well defined in the unicode standard.

              1 Reply Last reply
              0
              • P Offline
                P Offline
                phedlund
                wrote on last edited by
                #7

                Tobias: Are you saying there is a bug here or is there something that can be done in the code to improve things?

                To further underline the inconsistency I have a save as html and print function for my table view also. These both use a QTextDocument with a QTextTable and here the alignment works as expected, i.e. Arabic is rtl in the table cells without me having to do anything special in code.

                1 Reply Last reply
                0
                • I Offline
                  I Offline
                  infoctopus
                  wrote on last edited by
                  #8

                  looks like a bug

                  Qt rulez

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    phedlund
                    wrote on last edited by
                    #9

                    http://bugreports.qt.nokia.com/browse/QTBUG-15908
                    https://bugs.kde.org/show_bug.cgi?id=175520

                    1 Reply Last reply
                    0
                    • I Offline
                      I Offline
                      infoctopus
                      wrote on last edited by
                      #10

                      great that the related KDE bug found. (It's always harder to find such bugs due to less users care of that features)

                      Qt rulez

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        phedlund
                        wrote on last edited by
                        #11

                        Well, that bug is assigned to me. It's just that I have now found the time and incentive to finally try to sort this out.

                        1 Reply Last reply
                        0
                        • I Offline
                          I Offline
                          infoctopus
                          wrote on last edited by
                          #12

                          phedlund, great!

                          Qt rulez

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved