ADE ADE - 2 months ago 33
Python Question

Autoscroll PyQT QTextWidget

How can I autoscroll to the bottom of my QTextEdit

in my GUI init function



self.mytext = QTextEdit()
self.cursor = QTextCursor(self.mytext.document())
self.mytext.setTextCursor(self.cursor)



and how I am adding to it in another function



self.cursor.insertText(str(self.user) + ": " + str(self.line.text()) + "\n")



any ideas *cheers

Answer

moveCursor method should do that. e.g.:

self.mytext.moveCursor(QtGui.QTextCursor.End)