Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] problem with cursor resetting at the beginning of the plainTextEdit
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kalster
    wrote on last edited by
    #1

    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);@

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kalster
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved