开发者

How to scroll QPlainTextEdit to top?

开发者 https://www.devze.com 2023-04-02 03:42 出处:网络
I would like to automatically scroll to the top in a QPlainTextEdit widget after put开发者_如何学运维 in some text. How can I realize that?myTextEdit -> moveCursor (QTextCursor::Start) ;

I would like to automatically scroll to the top in a QPlainTextEdit widget after put开发者_如何学运维 in some text. How can I realize that?


myTextEdit -> moveCursor (QTextCursor::Start) ;
myTextEdit -> ensureCursorVisible() ;


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

QScrollBar *vScrollBar = yourTextEdit->verticalScrollBar();
vScrollBar->triggerAction(QScrollBar::SliderToMinimum);
0

精彩评论

暂无评论...
验证码 换一张
取 消