【发布时间】:2020-09-20 06:59:04
【问题描述】:
我有一个 QLabel,它的未知文本必须是从右到左的,无论它是哪种语言。所以我写了这段代码:
def add_label(self):
text = self.text_input.text() # self.text_input is a QLineEdit
widget = QLabel(text)
widget.setAlignment(Qt.AlignRight)
widget.setStyleSheet("color: #000000")
self.layout.addWidget(widget) # self.layout is a QVBoxLayout
# I can't setAlignment for self.layout because there is some other QLabels in there that have a LtR alignment.
这里的问题是当我在self.text_input 中编写波斯文本并运行add_label 函数(通过按下按钮)时,它会自动将对齐方式更改为 RtL,当我调用 widget.setAlignment(Qt.AlignRight) 时它会改变回到LtR。但无论是哪种语言,我都希望它是 RtL。
如何解决这个问题?
【问题讨论】:
标签: python python-3.x pyqt5 pyside2 farsi