Qt Code:
  1. self.undoStack = QUndoStack()
  2. self.undoAction = self.undoStack.createUndoAction()
  3. 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
Qt Code:
  1. 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 ()
Qt Code:
  1. self.undoStack = QUndoStack(self)
  2. self.undoAction = self.undoStack.createUndoAction()
  3. 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.