PDA

View Full Version : Achieve to undo/redo stack from widgets....¿posible?



dehm
16th August 2017, 18:42
This is my question. I have a widget with a undo button and a redo button and two QtextEdit.
I can call to the undo()/redo() methods from each QTextEdit and executing this actions in one or other widget, but I would like to store the actions for both of them.

I mean that if I change QtextEdit 1, and next I change QTextEdit2 and finally I change again QTextEdit1, I would like that if I press Undo button three times then it undoes second change of QtextEdit 1, after it undoes QTextEdit 2 changes and finally it undoes first change of QTextEdit 1 .

I think that there are two ways for get it:

1.- Create all the necessaries commands I want to push (I see it tedious and obligate me to do again a work that exist into the QTextEdit) or...
2.- Use the undo/redo stack from the widgets (the QTextEdit) for get the commands and use in my main undoStack, but looks that there aren't any method for access to stacks.

My question is:

¿Is possible the things I say? (access to the stack from QTextEdit -or other widget- for push this commands in a "main" stack)

If not....¿may I define each action I want to add to QUndoStack?

sedi
23rd August 2017, 00:50
As there seems to be no information about the number of possible undos/redos while the user is inputting, I don't see a way to properly monitor the changes and afterwards dispatch the undo/redo without. With looking into the source code of QTextEdit you might find ideas, but I think you'll probably have to implement this by yourself.