[Interest] QTextDocument/QTextCursor: inserting, editing blocks

Vojtěch Král vojtech at kral.hk
Wed Sep 11 18:13:41 CEST 2013


Hi,
I don't understand how to edit text blocks in QTextDocument using 
QTextCursor.
So far I've been inserting text using QTextCursor::insertText() and it 
worked fine,
however, I later noticed that each call to QTextCursor::insertText() 
creates a new QTextBlock within the document.

Is it possible to somehow append text to an existing block instead of 
creating a new one?
My concern is that this might incur a lot of overhead both in terms of 
cpu time and memory, especially once the document contains a lot of 
text.

In this regard I'm also wondering what is the purpose of void 
QTextCursor::insertBlock().
I can't seem to find a way how this group of functions would ever be 
useful, but I assume there is a reason they are provided.

If it is of any relevance I'm using QTextDocument to display output of a 
console application, including support color of formatting/coloring 
escape sequences etc., which works fine, apart from the large block 
count problem.

Thanks for any advice.
VK




More information about the Interest mailing list