QGraphicsTextItem RightToLeft 文本
我必须将一些波斯语文本写入 QGraphicsTextItem
,但我找不到如何使 QGraphicsTextItem
写入 RightToLeft!。
任何人都可以帮助我吗?
我尝试了这种方法,但它对我不起作用:
class DiagramTextItem(QtGui.QGraphicsTextItem):
def __init__(self, parent=None, scene=None):
super(DiagramTextItem, self).__init__(parent, scene)
doc =QtGui.QTextDocument ('''شسشس
یییییگ''')
txtOpt = QtGui.QTextOption()
txtOpt.setAlignment(QtCore.Qt.AlignRight)
doc.setDefaultTextOption(txtOpt)
谢谢。
I have to write some Farsi texts to a QGraphicsTextItem
, but I can't find how I can make QGraphicsTextItem
to write RightToLeft!.
Can any one help me?.
I tryed this way but it didn't work for me:
class DiagramTextItem(QtGui.QGraphicsTextItem):
def __init__(self, parent=None, scene=None):
super(DiagramTextItem, self).__init__(parent, scene)
doc =QtGui.QTextDocument ('''شسشس
یییییگ''')
txtOpt = QtGui.QTextOption()
txtOpt.setAlignment(QtCore.Qt.AlignRight)
doc.setDefaultTextOption(txtOpt)
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您可以将 QTextOption.setTextDirection 与 < a href="http://developer.qt.nokia.com/doc/qt-4.8/qt.html#LayoutDirection-enum" rel="nofollow">Qt.RightToLeft。
但请注意,您可能需要在设置文本之前设置方向:
如果这不起作用,请尝试将光标设置在
QGraphicsTextItem
上:It looks like you could use QTextOption.setTextDirection with Qt.RightToLeft.
But note that you may need to set the direction before you set the text:
If that doesn't work, try setting the cursor on the
QGraphicsTextItem
: