<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QTreeWidget Delete Last Item]]></title><description><![CDATA[<p dir="auto">hi<br />
when QTreeWidget just have 1 item &amp; if i want delete the item application crash &amp; when have more than 1 item work fine, this is my code :</p>
<pre><code>ui-&gt;TreeWidget-&gt;takeTopLevelItem(currentItem);
</code></pre>
]]></description><link>https://forum.qt.io/topic/69647/qtreewidget-delete-last-item</link><generator>RSS for Node</generator><lastBuildDate>Wed, 05 Aug 2026 07:50:02 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/69647.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 26 Jul 2016 18:36:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QTreeWidget Delete Last Item on Wed, 27 Jul 2016 17:05:12 GMT]]></title><description><![CDATA[<p dir="auto">Maybe there is some side effect even that happens which is actually the source of the crash.  For example, you might have a problem if you don't handle the signal itemSelectionChanged() properly (i.e. you don't expect a no-selection case).</p>
<p dir="auto">I tried this without problems:</p>
<pre><code>	while(d_machine_parameter_tree-&gt;topLevelItemCount())
	{
		d_machine_parameter_tree-&gt;takeTopLevelItem(0);
	}
</code></pre>
<p dir="auto">Qt 5.6.0, OSX 10.10.5</p>
<p dir="auto">Note:  You should delete the returned widget otherwise it is a memory leak.</p>
]]></description><link>https://forum.qt.io/post/339593</link><guid isPermaLink="true">https://forum.qt.io/post/339593</guid><dc:creator><![CDATA[Rondog]]></dc:creator><pubDate>Wed, 27 Jul 2016 17:05:12 GMT</pubDate></item><item><title><![CDATA[Reply to QTreeWidget Delete Last Item on Wed, 27 Jul 2016 13:30:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> Hi<br />
No, i don't  have stack trace &amp; currentItem is valid even i test whit this code when i have only 1 item:</p>
<pre><code>ui-&gt;TreeWidget-&gt;takeTopLevelItem(0);
</code></pre>
<p dir="auto">and app crash</p>
]]></description><link>https://forum.qt.io/post/339563</link><guid isPermaLink="true">https://forum.qt.io/post/339563</guid><dc:creator><![CDATA[ARASHz4]]></dc:creator><pubDate>Wed, 27 Jul 2016 13:30:39 GMT</pubDate></item><item><title><![CDATA[Reply to QTreeWidget Delete Last Item on Tue, 26 Jul 2016 22:38:25 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Do you have a stack trace ?</p>
<p dir="auto">Are you sure currentItem is valid ?</p>
]]></description><link>https://forum.qt.io/post/339443</link><guid isPermaLink="true">https://forum.qt.io/post/339443</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 26 Jul 2016 22:38:25 GMT</pubDate></item></channel></rss>