<?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[[SOLVED] QTreeView subitem not being added correctly]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I'm trying to add a subitem to the selected QTreeWidget item using the following code:</p>
<pre><code>        QTreeWidgetItem *itm = new QTreeWidgetItem(this-&gt;ui-&gt;Defs_tree);
        itm-&gt;setText(0, name);
        if (subitem)
        {
            QList&lt;QTreeWidgetItem *&gt; lst = this-&gt;ui-&gt;Defs_tree-&gt;selectedItems();
            if ( lst.count() == 1 )
                lst.at(0)-&gt;addChild(itm);
        } 
</code></pre>
<p dir="auto">But, the subitem gets added outside the selected item: and I'm still unable to solve the issue.<br />
I need some help.<br />
Thanks.</p>
]]></description><link>https://forum.qt.io/topic/55718/solved-qtreeview-subitem-not-being-added-correctly</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 11:55:16 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/55718.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 26 Jun 2015 09:10:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED] QTreeView subitem not being added correctly on Fri, 26 Jun 2015 12:00:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chris-kawa">@<bdi>Chris-Kawa</bdi></a> Yes, I missed that. Thanks a lot for your help.</p>
]]></description><link>https://forum.qt.io/post/279868</link><guid isPermaLink="true">https://forum.qt.io/post/279868</guid><dc:creator><![CDATA[kdev]]></dc:creator><pubDate>Fri, 26 Jun 2015 12:00:04 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] QTreeView subitem not being added correctly on Fri, 26 Jun 2015 11:52:32 GMT]]></title><description><![CDATA[<p dir="auto">The first line of your code puts the item into the tree already. Remove the tree parameter and you should be good to go. Be careful of leaking that item though, as you only seem to insert it conditionally.</p>
]]></description><link>https://forum.qt.io/post/279867</link><guid isPermaLink="true">https://forum.qt.io/post/279867</guid><dc:creator><![CDATA[Chris Kawa]]></dc:creator><pubDate>Fri, 26 Jun 2015 11:52:32 GMT</pubDate></item></channel></rss>