Using QUndoStack with several widgets

0

Imagine a Widget with two buttons Undo and Redo and two QTextEdit , called Editor1 and Editor2

We know that every QTextEdit has its method undo() and redo() So far all I see, and I am able to do, is that when I press the buttons Undo and Redo I call the method undo() and redo() of the active editor at that moment and execute the script to do or undo.

But what I would like is to have the stack QUndoStack that will store every change of each QTextEdit so that if for example I modify a text in Editor1 , then I change it to Editor2 and I make changes, and go back to the first one, when I press the Undo button, do not call the method undo() of the active editor ( Editor1 ) but undo the last action executed, which was done in Editor2 .

I can think of two ways:

1 .- Redefine each and every one of the actions that each editor would do (write, erase, format ...) to make them happen by the stack QUndoStack of the main widget. I see it very long and tedious.

2 .- Try that each time an action of each QTextEdit passes to its particular stack it can somehow pass to the stack of the widget principal, which I do not know if it's feasible.

But I do not know if there is another better way and in any case, at least, how it would be done in point 2

The question closest to mine is this one, but it is not answered: link

    
asked by user3733164 16.08.2017 в 12:03
source

0 answers