self.undoAction = self.undoStack.createUndoAction()
self.redoAction = self.undoStack.createRedoAction()
self.undoStack = QUndoStack()
self.undoAction = self.undoStack.createUndoAction()
self.redoAction = self.undoStack.createRedoAction()
To copy to clipboard, switch view to plain text mode
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()
self.undoAction = self.undoStack.createUndoAction()
To copy to clipboard, switch view to plain text mode
, 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.undoAction = self.undoStack.createUndoAction()
self.redoAction = self.undoStack.createRedoAction()
self.undoStack = QUndoStack(self)
self.undoAction = self.undoStack.createUndoAction()
self.redoAction = self.undoStack.createRedoAction()
To copy to clipboard, switch view to plain text mode
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.
Bookmarks