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. How to do right to Left text in QtextEdit
Forum Updated to NodeBB v4.3 + New Features

How to do right to Left text in QtextEdit

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 370 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.
  • S Offline
    S Offline
    summit
    wrote on last edited by
    #1

    With the following code the QtextEdit properly displays hebrew text.

    QTextOption txtOption;
    txtOption.setTextDirection(Qt::RightToLeft);
    txtEdit->document()->setDefaultTextOption(txtOption);
    
    
    

    But when i get this text from txtEdit it reverses the order.

    std::string stdstrTxt = (textUTF8Edit->toPlainText().toUtf8().toStdString());
    

    As shown in the image the font is in proper right to left order in the text box but when accessed from the textbox and rendered it changes the order to Left to right.
    textEdit.png

    Christian EhrlicherC 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #6

      You have to tell harfbuzz to render it as rtl instead ltr.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • S summit

        With the following code the QtextEdit properly displays hebrew text.

        QTextOption txtOption;
        txtOption.setTextDirection(Qt::RightToLeft);
        txtEdit->document()->setDefaultTextOption(txtOption);
        
        
        

        But when i get this text from txtEdit it reverses the order.

        std::string stdstrTxt = (textUTF8Edit->toPlainText().toUtf8().toStdString());
        

        As shown in the image the font is in proper right to left order in the text box but when accessed from the textbox and rendered it changes the order to Left to right.
        textEdit.png

        Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @summit said in How to do right to Left text in QtextEdit:

        and rendered it changes the order to Left to

        How do you render it?

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        0
        • S Offline
          S Offline
          summit
          wrote on last edited by
          #3

          @Christian-Ehrlicher I use HarfBuzz along with Opengl

          Christian EhrlicherC 1 Reply Last reply
          0
          • S summit

            @Christian-Ehrlicher I use HarfBuzz along with Opengl

            Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @summit so how is this a Qt problem then?

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0
            • S Offline
              S Offline
              summit
              wrote on last edited by
              #5

              @Christian-Ehrlicher I just now realize it is related to harfbuzz , Thank you for your response.

              1 Reply Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #6

                You have to tell harfbuzz to render it as rtl instead ltr.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                1
                • S summit has marked this topic as solved on

                • Login

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