View Full Version : Scrolling QTextEdit
Dayton
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?
wysota
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();
vs->setValue(vs->maximum());
or use QPlainTextEdit::ensureCursorVisible() with QTextCursor::movePosition()
shentian
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.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.