Actually, I think it is better to have the garbage collector in the scene, not the view, because you can have many views for the same items and it could get messy.
Actually, I think it is better to have the garbage collector in the scene, not the view, because you can have many views for the same items and it could get messy.
Just to clarify, the code I have does seem to work, (items delete themselves). The only concern I have is if I'm creating a race condition or something. I did have one random crash once and am concerned that it might have been caused by that.
Garbage collector is an option too, or perhaps emitting a signal to get the scene to delete the item (queuedconnection of course).
yes, that is the reason.
I just thought a garbage collector would be more elegant... Queued connections are designed more for inter-thread communications. But I guess they could work... If not, you can always use postEvent.Garbage collector is an option too, or perhaps emitting a signal to get the scene to delete the item (queuedconnection of course).
Thanks. I'll give the garbage collector a try.
How about QObject::deleteLater() ...?
Bingo. Thanks elcuco, I vaguely remembered such a function existing, but couldn't find it anymore.
Bookmarks