QTextCursor cursor = textEdit->textCursor(); QTextBlockFormat blockFormat = cursor.blockFormat(); blockFormat.setAlignment(Qt::AlignCenter); cursor.setBlockFormat(blockFormat);
QTextCursor cursor = textEdit->textCursor(); QTextBlockFormat blockFormat = cursor.blockFormat(); blockFormat.setLeftMargin(20); blockFormat.setRightMargin(20); cursor.setBlockFormat(blockFormat);
QTextCursor cursor = textEdit->textCursor(); QTextBlockFormat blockFormat = cursor.blockFormat(); blockFormat.setLineHeight(150, QTextBlockFormat::ProportionalHeight); cursor.setBlockFormat(blockFormat);These examples demonstrate how QTextBlock blockFormat can be used to apply formatting to blocks of text in a QTextDocument. The library used in these examples is the Qt framework.