Setting Text in QPlainTextEdit without Clearing Undo/Redo History
Hello.
How can I set text in QPlainTextEdit without clearing the undo/redo history?
Re: Setting Text in QPlainTextEdit without Clearing Undo/Redo History
You can try
- access to the document
- create a text cursor
- select all text in the document
- delete selected text
- insert new text
Code:
curs.removeSelectedText ();
curs.insertText (newText);
Re: Setting Text in QPlainTextEdit without Clearing Undo/Redo History
I haven't tried it, but maybe using QCursor directly wont clear the history.
...too late.
Re: Setting Text in QPlainTextEdit without Clearing Undo/Redo History
Thank you so much. It works. But it also takes the empty document (When you remove selected text) into the undo/redo history.
Re: Setting Text in QPlainTextEdit without Clearing Undo/Redo History
delete the line
Code:
curs.removeSelectedText ();
from my code
Re: Setting Text in QPlainTextEdit without Clearing Undo/Redo History
How could I not think about that!?
Thank you so much. It works perfect now!