Nominate our 2022 Qt Champions!

[SOLVED] problem with cursor resetting at the beginning of the plainTextEdit

  • at the code below, the <b> </b> is inserted at the end of the plainTextEdit line. the problem is that the cursor is reset to the beginning of the line. i want the cursor to be at the end of the line. how do i do that? tc.keepPositionOnInsert(); is not working. thank you in advanced.
    @ QTextCursor tc = plainTextEdit->textCursor();
    selectStart = tc.selectionStart();
    selectEnd = tc.selectionEnd();
    message = plainTextEdit->toPlainText();
    message = message.insert(selectEnd, "</b>");
    message = message.insert(selectStart, "<b>");

  • solved. i needed the following code.
    @ tc.movePosition(QTextCursor::End);

Log in to reply