How to program scrollbar to jump to bottom/top in case of change in QPlainTextEdit or QTextEdit area?

前端 未结 5 1175
失恋的感觉
失恋的感觉 2020-12-10 13:29

How to program scrollbar to jump to bottom/top in case of change in QPlainTextEdit or QTextEdit area? It looks like it doesn\'t have any controlling function.

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-10 14:13

    You can use the 'ensureCursorVisible' method:

    void QTextEdit::ensureCursorVisible ()
    Ensures that the cursor is visible by scrolling the text edit if necessary.
    

    This is not a slot, though, so you can't connect it to any signal -- you'll have to create something yourself that you can connect to the void textChanged() signal.

    Disclaimer: I may have misunderstood your question -- I assume you want to scroll down when some text is appended to the text.

提交回复
热议问题