Unsolved Changing QTextBlock behavior for a QTextDocument
-
The documentation says that a QTextDocument is compose of QTextBlock.
Every QTextBlock is determine by a sequence of characters ending by the special character \n.But I can't seem to find how exactly it would be possible to change this behavior.
For instance, I would like to define a QTextBlock as "one or more consecutive lines of text, separated by one or more blank lines", just like Markdown paragraph.Is there way to change the behavior of a QTextDocument so it produces QTextBlock the way I want?
-
@lzrdkng
you are talking about thetoPlainText()
method right?A possibility is to traverse the QTextDocument yourself and generate the string (
QTextBlock::text()
) and insert your custom block separators.Untested:
QString text; QTextBlock block = textDoc->firstBlock(); while( block.isValid() ) { text.append( block.text() ); text.append( MY_SEPARATOR_STRING ); block = block.next(); }
-
@raven-worx Thank for the idea! I'll dig into it!