title: How do I delete a top level QTreeWidgetItem from a QTreeWidget?
body: <p>I'm attempting to remove a top level tree widget item if there are no child nodes within the top level item. What is the correct way to do this? I can't seem to find the API call within Qt's documentation. Is it safe to just call delete on the top level tree widget item? I haven't run into any issues yet, but I'd like to know if that's safe practice. Thanks much.</p>
  
  <pre><code>if(topLevelTreeWidgetItem-&gt;childCount() &gt; 1) {
    topLevelTreeWidgetItem-&gt;removeChild(childItem);
  }
  else
  {
    delete topLevelTreeWidgetItem;
  }
  </code></pre>