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:
  1. void SongItem::onAnimationFinished() {
  2. onAnimationValueChanged(1.0);
  3. animationTimeline->disconnect(this);
  4. if(!opacity)
  5. delete this;
  6. }
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