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
Post a Comment