title: QGraphicsScene::clear() clearing scene but not the view
body: <p>I use a custom class (<code>Configuration</code>) derived from <code>QGraphicsItem</code> and I add its objects to a <code>QGraphicsScene</code>, which is then displayed in a <code>QGraphicsView</code>. Usual stuff. What Im doing exactly is drawing a tree, in multiple steps, one level a step, each node beeing my custom <code>QGraphicsItem</code>.</p>
  
  <p><img src="https://i.stack.imgur.com/SfTcr.png" alt="enter image description here"></p>
  
  <p>Here a screenshot. The tree happens to be sequential in the simple case. </p>
  
  <p>I first draw the root node. The signal that triggers that is fired after the user entered a string.</p>
  
  <pre><code>void MainWindow::drawRootSlot(ConfigTreeBuilder &amp; builder)//this is a slot
  {
      c_scene-&gt;clear();  //the clear cause headache. i'll expain
  
      Configuration* conf = new Configuration(builder.getNodesX(), builder.getNodesY(),builder.getNodesConfig());
  //code
      c_scene-&gt;addItem(conf);
  //code
  }
  </code></pre>
  
  <p>Each subsequent <code>Configuration</code> is draw inside another slot. </p>
  
  <pre><code>void MainWindow::configTreeSlot(ConfigTreeBuilder &amp; builder)    //SLOT!!!
  {
      while(builder.chooseNextNode()) {
  
          Configuration* conf = new Configuration(builder.getNodesX(), builder.getNodesY(), builder.getNodesConfig());
  
         //code, while loop    
              QGraphicsLineItem *edge = c_scene-&gt;addLine(QLineF(*(parentsPoint), conf-&gt;getLeftOrigin()));
              edge-&gt;setZValue(-1); //below the Configuration item
  
  
          c_scene-&gt;addItem(conf);
      }
  
  }
  </code></pre>
  
  <p>All works fine when done for the first time. When I  enter a new string, resetting the tree, dark magic happens. What I expected to it do is: call <code>drawRootSlot()</code>,  deleting the whole tree (<code>c_scene-&gt;clear()</code>), draw a new root node. And, if I put a debugger breakpoint inside <code>drawRootSlot()</code> this is exactly what happens! But when I run it (without breakpoints), what I get is this:</p>
  
  <p><img src="https://i.stack.imgur.com/NT4wy.png" alt="enter image description here"></p>
  
  <p>The previous tree got mangled, but not deleted. The scene gets indeed cleared of its items (printed that) but the view  does not reflect that. But again, when I put a breakpoint inside <code>drawRootSlot()</code> thhe view and the scene are in sync.</p>
  
  <p>I tried to delete the scene object, and instaciate a new one instead of calling <code>c_scene-&gt;clear()</code>, to guarantee it empty. Then the changes are reflected on the view (the first time drawing always works).</p>
  
  <p>So, I have no idea what to deduce from these symptoms. It works as expected with a breakpoint or with a freshh <code>QGraphicsScene</code> object. It does not when just using <code>c_scene-&gt;clear()</code>. One couldsay I just messed up the parent-object/child-object relation, but <code>clear()</code> <em>does</em> remove items from the view... I tried calling it right after <code>c_scene-&gt;addItem()</code>.</p>
  
  <p>What is this sorrcery? One that makes me believe I'm not actually stupid?</p>
  
  <p><strong>EDIT:</strong> Whats interesting and may be a hint to the real problem, is that when <code>c_scene-&gt;clear()</code> is called, the edges of the tree, which are normal <code>QGraphicsLineItem</code>s, are indeed deleted in all cases (breakpoint or not). Something to do with them <em>not</em> beeing custom?</p>