<?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[Prevent Destruction of QList&lt;QTreeWidgetItem *&gt;]]></title><description><![CDATA[<p dir="auto">I'm creating a <code>QList&lt;QTreeWidgetItem *&gt;</code> which holds an INI-backed list of virtual files and folders specified by the end user.</p>
<p dir="auto">The problem is that because the items from the <code>QList</code> are associated with a <code>QTreeWidget</code> when presented to the user, they are also destroyed when the <code>QTreeWidget</code> is destroyed.</p>
<p dir="auto">Is there any way I can stop this happening?</p>
<p dir="auto">I have looked into using a <code>QTreeView</code> but the implementation seems to be pretty horrible and would prefer using the <code>QTreeWidget</code> if it is possible.</p>
]]></description><link>https://forum.qt.io/topic/99050/prevent-destruction-of-qlist-qtreewidgetitem</link><generator>RSS for Node</generator><lastBuildDate>Thu, 22 Oct 2026 22:41:24 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/99050.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 28 Jan 2019 13:50:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Prevent Destruction of QList&lt;QTreeWidgetItem *&gt; on Mon, 28 Jan 2019 14:10:24 GMT]]></title><description><![CDATA[<p dir="auto">@J-Hilk Thanks for your reply.</p>
<p dir="auto">Unfortunately this doesn't work - the items are still munched up by the <code>QTreeWidget</code>.</p>
<p dir="auto">I guess I'm just going to have to bite the bullet and figure out how to use a <code>QTreeView</code>.</p>
]]></description><link>https://forum.qt.io/post/507808</link><guid isPermaLink="true">https://forum.qt.io/post/507808</guid><dc:creator><![CDATA[webzoid]]></dc:creator><pubDate>Mon, 28 Jan 2019 14:10:24 GMT</pubDate></item><item><title><![CDATA[Reply to Prevent Destruction of QList&lt;QTreeWidgetItem *&gt; on Mon, 28 Jan 2019 13:55:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/webzoid">@<bdi>webzoid</bdi></a><br />
in the destructor of your QTreeWidget call <a href="http://doc.qt.io/qt-5/qtreewidgetitem.html#takeChildren" target="_blank" rel="noopener noreferrer nofollow ugc">takeChildren</a> that should take all items from the widget and return it as a list.<br />
You can ignore the returned list, as you have one in memory already.</p>
<p dir="auto">This is untested, I'm not 100% sure the TreeWidget won't still delete the items.</p>
]]></description><link>https://forum.qt.io/post/507804</link><guid isPermaLink="true">https://forum.qt.io/post/507804</guid><dc:creator><![CDATA[J.Hilk]]></dc:creator><pubDate>Mon, 28 Jan 2019 13:55:54 GMT</pubDate></item></channel></rss>