def itemChange(self, change, value): if change == QGraphicsItem.ItemPositionChange and self.scene(): command = CommandMoveItem(self, value) self.scene().undoStack.push(command) return QGraphicsLineItem.itemChange(self, change, value)
def itemChange(self, change, value): if change == QGraphicsItem.ItemPositionChange and self.scene(): # If the position changes then do so with an redo/undo command command = CommandMoveItem(self, value) self.scene().undoStack.push(command) return super().itemChange(change, value)