title: How to delete all QGraphicsItem from QGraphicsScene
body: <p>I've written a derived class from <code>QGraphicsScene</code>. At a point I need to remove all items from the scene and I want the items to be physically destroyed (destructor called). I tried the following:</p>
  
  <pre><code>QList&lt;QGraphicsItem*&gt; all = items();
  for (int i = 0; i &lt; all.size(); i++)
  {
      QGraphicsItem *gi = all[i];
      removeItem(gi);
      delete gi; // warning at this line
  }
  </code></pre>
  
  <p>Qt Creator emits a warning: warning: C4150: deletion of pointer to incomplete type 'QGraphicsItem'; no destructor called</p>
  
  <p>I'm not sure why is that. <code>QGraphicsItem</code> has virtual destructor so the items should be deleted from memory.</p>
  
  <p>If this is not the right way, how can I delete all <code>QGraphicsItem</code>s from <code>QGraphicsScene</code>? Note that I know when the scene is deleted, all items will also be deleted. But i want to remove items from scene and draw other items. I want the removed items to be deleted from memory.</p>