QTextBlock block = document->findBlock(0); // Gets the first block in the document QTextCursor cursor(block); cursor.movePosition(QTextCursor::StartOfBlock); cursor.setPosition(cursor.position(), QTextCursor::KeepAnchor); QTextBlockFormat format; format.setIndent(2); // Sets the block's indentation to 2 cursor.setBlockFormat(format);
QTextBlock block = document->findBlock(0); QTextCursor cursor(block); cursor.movePosition(QTextCursor::StartOfBlock); cursor.setPosition(cursor.position(), QTextCursor::KeepAnchor); QTextBlockFormat format; format.setTopMargin(10); // Sets the block's top margin to 10 format.setBottomMargin(10); // Sets the block's bottom margin to 10 cursor.setBlockFormat(format);This code example sets the top and bottom margins of the first block in the document to 10. This package is included in the Qt framework.