How to scroll QPlainTextEdit to top?

2020-07-06 04:45发布

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

2条回答
Lonely孤独者°
2楼-- · 2020-07-06 05:30
myTextEdit -> moveCursor (QTextCursor::Start) ;
myTextEdit -> ensureCursorVisible() ;
查看更多
地球回转人心会变
3楼-- · 2020-07-06 05:45

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

QScrollBar *vScrollBar = yourTextEdit->verticalScrollBar();
vScrollBar->triggerAction(QScrollBar::SliderToMinimum);
查看更多
登录 后发表回答