Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autoscroll PyQT QTextWidget

Tags:

python

pyqt

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")
like image 855
ADE Avatar asked Oct 15 '11 15:10

ADE


2 Answers

moveCursor method should do that. e.g.:

self.mytext.moveCursor(QtGui.QTextCursor.End)
like image 189
Avaris Avatar answered Sep 29 '22 19:09

Avaris


I've found the following to work:

from PyQt4 import QtGui

self.display = QtGui.QTextBrowser()
self.display.verticalScrollBar().setValue(
    self.display.verticalScrollBar().maximum())

Good luck!

like image 44
PyThon No0b Avatar answered Sep 29 '22 20:09

PyThon No0b