In that example, the 'deletion' does not (really) delete.
It just 'moves' the QGraphicsItem from the scene to the Command.
That way, it is no longer visible, but the command can reinsert it for a redo.

Think of it like the deleting of files on KDE or windows: Hitting Delete usually does not really delete, but only move the files into the trashcan folder. It's about the same think that happens here.

It is possible to actually delete the item. But then you have to implement a different way of restoring it in case of a redo.
(E.g you could implement a method 'serialize' and 'unserialize' in your items that save the relevant data to a QByteArray.)

HTH