Problem with mixing Latin and Arabic text in QTextEdit

38 Views Asked by At

I'm using QTextEdit to show messages in my app. My problem is that QTextEdit doesn't show messages correctly when I use Latin and Arabic text simultaneously.

Correct order:

enter image description here

Incorrect order:

enter image description here

As you can see, the QTextEdit doesn't show message in correct order.

I've tried to solve the problem using CSS style, but it didn't work.

1

There are 1 best solutions below

0
Arash Rafiee On

Thanks guys. I've solved the problem by the following code:

text_option = QTextOption(QtCore.Qt.AlignmentFlag.AlignLeft) text_option.setTextDirection(QtCore.Qt.LayoutDirection.RightToLeft) self.conversationsTextEdit.document().setDefaultTextOption(text_option)