python - QGraphicsTextItem RightToLeft text -



python - QGraphicsTextItem RightToLeft text -

i have write farsi texts qgraphicstextitem , cant find how can create qgraphicstextitem wirte righttoleft ! can 1 help me ?

i tryed way didnt worked 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)

ty

it looks utilize qtextoption.settextdirection qt.righttoleft.

but note may need set direction before set text:

class diagramtextitem(qtgui.qgraphicstextitem): def __init__(self, parent=none, scene=none): super(diagramtextitem, self).__init__(parent, scene) doc = qtgui.qtextdocument() txtopt = qtgui.qtextoption() txtopt.settextdirection(qtcore.qt.righttoleft) doc.setplaintext('''شسشس یییییگ''')

if doesn't work, seek setting cursor on qgraphicstextitem:

class diagramtextitem(qtgui.qgraphicstextitem): def __init__(self, parent=none, scene=none): super(diagramtextitem, self).__init__(parent, scene) cursor = self.textcursor() format = cursor.charformat() format.setlayoutdirection(qtcore.qt.righttoleft) cursor.setformat(format) self.settextcursor(cursor) self.setplaintext('''شسشس یییییگ''')

python qt pyqt qgraphicsscene qgraphicstextitem

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -