Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-55618

QTextEdit undo fails after using QTextCursor (even with begin/end-EditBlock()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.5.1
    • GUI: Text handling
    • None
    • Linux 64-bit

      In a slot connected to QTextEdit's cursorPositionChanged signal I have:

      cursor = editor->textCursor();
      cursor.beginEditBlock();
      cursor.select(QTextCursor::WordUnderCursor):
      word = cursor.selectedText()
      if (!word.isEmpty) {
      replacement = find_replacement_for(word);
      if (!replacement.isEmpty() && replacement != word)

      { cursor.insertText(replacement); }

      }
      cursor.endEditBlock();

      If I replace say "cmd" with "command" using the above code when I undo interactively, all that happens is that the cursor is moved back to where it was after entering "cmd", i.e., com^mand.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            esabraha Eskil Abrahamsen Blomfeldt
            mark@qtrac.eu Mark Summerfield
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes