View Full Version : Scrolling QTextEdit

3rd June 2009, 20:58
I am trying to use Qt's QTextEdit widget to display status messages as my application progresses. As the display fills up, a vertical scroll bar is displayed. What I would also like to happen is for the display to automatically scroll so that the new text is displayed. How do I do that?

3rd June 2009, 21:08
I suggest you use QPlainTextEdit instead of QTextEdit, it has better performance when no advanced editing capabilities are required.

As for scrolling you can either use:

QScrollBar *vs = verticalScrollBar();

or use QPlainTextEdit::ensureCursorVisible() with QTextCursor::movePosition()

3rd June 2009, 22:11
Also consider using QTextBrowser, a subclass of QTextEdit, if the user shoudn't be able to edit the text.

I prefer to use a view class to display messahes, such as QListView or QTableView.