How to scroll QPlainTextEdit to top?
Asked Answered
B

2

11

I would like to automatically scroll to the top in a QPlainTextEdit widget after put in some text. How can I realize that?

Bushcraft answered 2/9, 2011 at 8:30 Comment(0)
K
20
myTextEdit -> moveCursor (QTextCursor::Start) ;
myTextEdit -> ensureCursorVisible() ;
Koeppel answered 2/9, 2011 at 9:34 Comment(0)
E
18

As QTextEdit inherits from QAbstractScrollArea, you can move its scrollbars:

QScrollBar *vScrollBar = yourTextEdit->verticalScrollBar();
vScrollBar->triggerAction(QScrollBar::SliderToMinimum);
Eastlake answered 2/9, 2011 at 9:17 Comment(1)
This is the most general solution to the issue of scrolling. (It answered my general question about scrolling to the top of widgets.)Durham

© 2022 - 2024 — McMap. All rights reserved.