Results 1 to 4 of 4

Thread: Controling the deletion of objects?

  1. #1

    Default Controling the deletion of objects?

    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.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Controling the deletion of objects?

    How are u allowing objects to be deleted ?
    As far as I understand, graphicsItems are not deleted by default...

  3. #3

    Default Re: Controling the deletion of objects?

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Controling the deletion of objects?

    So make a check before you remove the item and only remove it if the check allows it.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.