PDA

View Full Version : Does self.undoStack.createUndoAction() automatically triggers some functions/events



helloworld12345
29th November 2017, 01:29
self.undoStack = QUndoStack()
self.undoAction = self.undoStack.createUndoAction()
self.redoAction = self.undoStack.createRedoAction()

Above are 3 lines of code.
Question 1. Would self.undoAction = self.undoStack.createUndoAction() automatically trigger some functions, because after it run the second line
self.undoAction = self.undoStack.createUndoAction(), it didn't run to the third line, but a function called setModel under QTreeView.

Question 2. I did a little Modification on above code by adding self to ()

self.undoStack = QUndoStack(self)
self.undoAction = self.undoStack.createUndoAction()
self.redoAction = self.undoStack.createRedoAction()

Then after it run first line, then went to selfModel of QTreeView, it didn't run the second line. Why does "self" make this difference, I though by default it's "self" if I leave it as blank.

Thanks a lot.