PDA

View Full Version : set default QTextBlockFormat for QTextDocument?



tuli
16th May 2016, 10:23
Hi,

I am formatting a QTextDocument in a specific way, most notably I change the line high to +1 for the entire document, which is done like this:



QTextCursor cursor(document());
QTextBlockFormat block;
do{
block = cursor.blockFormat();
block.setLineHeight(1, QTextBlockFormat::LineDistanceHeight);
cursor.setBlockFormat(block);
} while(cursor.movePosition(QTextCursor::NextBlock)) ;


This has been identified as a major performance bottleneck (in particular the cursor.setBlockFormat call).

Since I am setting always the same thing for the entire document - surely there has to be a better way of setting the format/line spacing as a default for the entire document? Perhaps even before inserting the text?


Thanks for your help.