I have a QTextEdit
that contains a QTextDocument
, which is being programatically edited using the QTextCursor
interface. The document is being edited with QTextCursor::insertText()
.
I load the text file being edited in chunks, so the initial size of the QTextDocument
might only be 20 lines even though the document is 100,000 lines. However, I want the QTextEdit
scrollbar to reflect the full size of the document instead of just the 20 line document it's currently displaying.
The QTextEdit's scrollbar range is set with QScrollBar::setMaximum()
which adjusts the scrollbar to the proper size on the initial opening of the file, but when QTextCursor::insertText()
is called the QScrollBar
's range is recalculated.
I've already tried calling QScrollBar::setMaximum()
after each QTextCursor::insertText()
event, but it just makes the whole UI jerky and sloppy.
Is there any way to keep the range of the QScrollBar
while the QTextDocument
is being modified?