I would like to automatically scroll to the top in a QPlainTextEdit widget after put in some text. How can I realize that?
Asked
Active
Viewed 9,929 times
2 Answers
20
myTextEdit -> moveCursor (QTextCursor::Start) ;
myTextEdit -> ensureCursorVisible() ;

TonyK
- 16,761
- 4
- 37
- 72
18
As QTextEdit
inherits from QAbstractScrollArea
, you can move its scrollbars:
QScrollBar *vScrollBar = yourTextEdit->verticalScrollBar();
vScrollBar->triggerAction(QScrollBar::SliderToMinimum);

alexisdm
- 29,448
- 6
- 64
- 99
-
This is the most general solution to the issue of scrolling. (It answered my general question about scrolling to the top of widgets.) – adam.baker Dec 03 '14 at 04:30