QTextEdit *textEdit = new QTextEdit(this); QTextCursor cursor = textEdit->textCursor(); cursor.insertText("Hello World!");
QTextEdit *textEdit = new QTextEdit(this); QTextCursor cursor = textEdit->textCursor(); cursor.setPosition(5); cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, 10);This code sets the cursor position to 5 and then uses the movePosition() method to select 10 characters to the right of the cursor. QTextCursor is part of the QtGui package in Qt.