QTextEdit *textEdit = new QTextEdit(); QTextDocument *doc = textEdit->document(); QTextCursor cursor(doc); // Begin edit block cursor.beginEditBlock(); // Append some text cursor.insertText("Hello, "); cursor.insertText("world!"); // Change the font size for the whole block QTextCharFormat format; format.setFontPointSize(18); cursor.setCharFormat(format); // End edit block cursor.endEditBlock();In this example, we create a new QTextEdit widget and get its QTextDocument. We then create a QTextCursor for the document and call beginEditBlock to start a new editing operation. We insert some text and set the font size for the entire block. Finally, we call endEditBlock to finish the editing operation. This code is part of the Qt core library.