How to scroll QPlainTextEdit to top?

橙三吉。 提交于 2019-12-09 15:49:14

问题


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);


来源:https://stackoverflow.com/questions/7280965/how-to-scroll-qplaintextedit-to-top

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!