I have some graphicsitems that need to delete themselves once they're no longer needed. Right now I have a fadeTo(float) function, which will set up an animation to fade the item to a particular opacity value.
If I go item->fadeTo(0), it will fade to transparent and then delete itself, like so:
Qt Code:
void SongItem::onAnimationFinished() { onAnimationValueChanged(1.0); animationTimeline->disconnect(this); if(!opacity) delete this; }To copy to clipboard, switch view to plain text mode
That function is hooked up to the finished() signal of the timeline.
So my question is: Is having an item delete itself in a slot safe? If not, what's the best way to do it?
Thanks,
leo
Bookmarks