I would like to automatically scroll to the top in a QPlainTextEdit widget after put in some text. How can I realize that?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
myTextEdit -> moveCursor (QTextCursor::Start) ;
myTextEdit -> ensureCursorVisible() ;
回答2:
As QTextEdit
inherits from QAbstractScrollArea
, you can move its scrollbars:
QScrollBar *vScrollBar = yourTextEdit->verticalScrollBar();
vScrollBar->triggerAction(QScrollBar::SliderToMinimum);