As far as I know (official source), Qt defines a block in a QTextDocument as a bunch of characters followed by \n or a similar character. Hence...
QTextDocument* doc = my_qtextedit.document();
QTextCursor cur = QTextCursor(doc);
cur.insertText("aaa\nbbb");
qDebug() << "nbr of blocks" << doc->blockCount();
... prints "nbr of blocks=2".
But I need to
- (1) divide my text into several parts, arbitrary demarcated. By example, I need to be able to split the sentence "I'm twenty" into four blocks : "I", "'", "m" and "twenty".
- (2) easily access and modify these parts (and display them in a QTextEdit object).
The current block mechanism is interesting thanks to the find(), begin(), ... functions/iterators but I can't see how to specialize it to fit my requirements.
Is there a way to achieve this ?
update : alas, it seems difficult.
update : QTextFragment only allows to modify the format of the text.