How to do right to Left text in QtextEdit
-
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.
-
You have to tell harfbuzz to render it as rtl instead ltr.
-
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.
@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?
-
@Christian-Ehrlicher I use HarfBuzz along with Opengl
-
@Christian-Ehrlicher I use HarfBuzz along with Opengl
@summit so how is this a Qt problem then?
-
@Christian-Ehrlicher I just now realize it is related to harfbuzz , Thank you for your response.
-
You have to tell harfbuzz to render it as rtl instead ltr.
-