在 QTextEdit 中混合拉丁语和阿拉伯语文本的问题

问题描述 投票:0回答:1

我正在使用 QTextEdit 在我的应用程序中显示消息。我的问题是,当我同时使用拉丁语和阿拉伯语文本时,QTextEdit 无法正确显示消息。

正确顺序:

enter image description here

顺序错误:

enter image description here

如您所见,QTextEdit 没有以正确的顺序显示消息。

我尝试使用CSS样式解决该问题,但没有成功。

python user-interface pyqt5 qtextedit
1个回答
0
投票

谢谢大家。我通过以下代码解决了这个问题:

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

© www.soinside.com 2019 - 2024. All rights reserved.