Qt Clear Undo History in a QTextEdit/QPlainTextEdit?
Asked Answered
E

1

5

I have a QPlainTextEdit and I'm building a progress dialog for it when opening large files. Rather than using setText, I want to add one line of text at a time by using QTextCursor.insertText. The problem is that when I do it this way, I can undo each line that was added... is there a way to clear the undo history?

Ember answered 15/8, 2014 at 5:23 Comment(0)
S
7

Use QTextDocument::clearUndoRedoStacks. Code:

editor->document()->clearUndoRedoStacks(); // default clears both

See docs if you want to clear just undo. Also, it's good idea to read docs of QTextDocument (and QTextCursor) when working with the editor widgets. Lots of functionality is "hidden" there.

Stallings answered 15/8, 2014 at 5:39 Comment(1)
Thank you so much dude, this has been bothering me forever. I've been looking everywhere and I forgot all about the textdocuemnt class.Ember

© 2022 - 2024 — McMap. All rights reserved.