// initialize QTextEdit and QTextCursor objects QTextEdit *textEdit = new QTextEdit(parent); QTextCursor cursor = textEdit->textCursor(); // move the cursor to the end of the document cursor.movePosition(QTextCursor::End); // insert a new paragraph at the end cursor.insertBlock();
// initialize QTextEdit and QTextCursor objects QTextEdit *textEdit = new QTextEdit(parent); QTextCursor cursor = textEdit->textCursor(); // move the cursor to the end of the current line cursor.movePosition(QTextCursor::EndOfLine); // insert a new line after the current one cursor.insertBlock(QTextBlockFormat(), QTextCharFormat());This example creates a new QTextEdit widget and inserts a new line after the current one. The package library used in these examples is Qt, a cross-platform application and UI framework for creating desktop and mobile applications.