QTextOption.setTabArray has no effekt in QTextEdit

  • Hi all,

    I am trying to modify the tab positions of an QTextEdit (see the code below)
    But it seems to have no effect at all. If I enter tabs ("\t") in the edit window,
    they still have the standard space of 80px them.

    Does anyone know what I am doing wrong, or is this a bug?

    #from PySide.QtCore import *
    #from PySide.QtGui import *
    from PyQt4.QtCore import *
    from PyQt4.QtGui import *
    import sys

    class MainWindow(QTextEdit):
    def init(self, *args, **kwargs):
    super(MainWindow, self).init(*args, **kwargs)

        opt = self.document().defaultTextOption()
        opt.setTabArray([100, 110, 270]) #has no effekt
        #opt.setTabStop(40)  #this works if uncommented
        print [t.position for t in self.document().defaultTextOption().tabs() ]

    def main():
    # Create a Qt application
    app = QApplication(sys.argv)
    w = MainWindow()
    print repr(w.toHtml())

    if name == "main":

  • Oh, no. Are you all conspired?

    Moderator will move this post to the "Bindings" forum. It's Genaral & Desktop - here only C++ questions! Your code written in Python - it means that you need to post it into Language Binidings forum.

  • This is not a problem with the Python binding. I only wrote it in python because the code is smaller. If you translate it in C++ you get the same efffect.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.