c++qtundoundo-redoqtextdocument

How can I access the QUndoStack of a QTextDocument?


How can I access the QUndoStack of a QTextDocument?

(For example, I want to be able to add custom QUndoCommand objects to the document's undo stack)


Solution

  • I have been reading the documentation and it doesn't seems to be a way to get the QUndoStack directly for the Widget.

    Probably the only way is to create your own QUndoStack object and manually add the changes and then re-implement the redo() / undo() slots. I would have a look to the source code, you can probably get most of the code you need from there to store the changes in QTextDocument.