PDA

View Full Version : Controling the deletion of objects?



mooreaa
4th July 2008, 07:34
Hello,

I have a QGraphicsItem derived class called wire, and it has children that are verticies. The verticies are selectable so that they can be manipulated.

The question is, is there a good way to detect if something is trying to delete this object, and prevent it or possible tell another object to be deleted?

My wire gets messed up when a vertex is unexpectedly removed. I'd like to make it notify the wire that a particular vertex is being deleted... and also a way to prevent some items from being delted at all.

aamer4yu
4th July 2008, 08:37
How are u allowing objects to be deleted ?
As far as I understand, graphicsItems are not deleted by default... :confused:

mooreaa
4th July 2008, 12:44
In my QGraphicsScene subbed class, if the delete key is pressed and there is a selection, I call removeItem() for each of the selected objects. I guess I can go through the list of items in the selection and have the scene class decide what to delete or not, but if I can i'd like to keep it up to the object how it deals with the removal.

wysota
4th July 2008, 19:08
So make a check before you remove the item and only remove it if the check allows it.