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.
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
: