[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>");
    plainTextEdit->setPlainText(message);@



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.