<?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[Can&#x27;t make child in Qtreeview using QStandardItemModel]]></title><description><![CDATA[<p dir="auto">Hi<br />
after reading some examples i still missing here something .<br />
i have Qtreeview for view and  QStandardItemModel for the data interface , also using  QSortFilterProxyModel subclass but i dont know if its relevant.<br />
this is my logic :<br />
first i create the model with the QWidget as the parent :<br />
@QStandardItemModel m_model = new QStandardItemModel(0,4,parent);<br />
then setSourceModel(m_model)  for the widget<br />
set the treeview with QSortFilterProxyModel. something like this :<br />
GroupProxyModel = new GroupSortFilterProxyModel;<br />
GroupProxyModel-&gt;setDynamicSortFilter(true);<br />
setSourceModel(createSubjectModel(parent));</p>
<p dir="auto">ui.treeView_mainwindow-&gt;setModel(GroupProxyModel);<br />
ui.treeView_mainwindow-&gt;setSortingEnabled(true);@</p>
<p dir="auto">then later i fill the first row like this :</p>
<p dir="auto">@QList&lt;QStandardItem *&gt; items;<br />
items.insert(0,new QStandardItem("Test 0"));<br />
<a href="http://items.at" target="_blank" rel="noopener noreferrer nofollow ugc">items.at</a>(0)-&gt;setEditable(false);<br />
m_model-&gt;insertRow(0,items);@</p>
<p dir="auto">until now every thing working fine and i see the row with the data . but when i like to<br />
add child to the row like this :</p>
<p dir="auto">@QModelIndex parentQModelIndex = m_model-&gt;item(0,0)-&gt;index();<br />
m_model-&gt;insertRows(0,1,parentQModelIndex);<br />
m_model-&gt;insertColumns(0,1,parentQModelIndex);<br />
QModelIndex indexB = m_model-&gt;index(0, 0, parentQModelIndex);<br />
m_model-&gt;setData(indexB,"Child test",Qt::DisplayRole);</p>
<p dir="auto">@<br />
but i dont see the child , why ?</p>
]]></description><link>https://forum.qt.io/topic/7483/can-t-make-child-in-qtreeview-using-qstandarditemmodel</link><generator>RSS for Node</generator><lastBuildDate>Wed, 05 Aug 2026 03:06:59 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/7483.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 11 Jul 2011 08:07:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Can&#x27;t make child in Qtreeview using QStandardItemModel on Mon, 11 Jul 2011 08:49:02 GMT]]></title><description><![CDATA[<p dir="auto">Try to use QStandardItemModel directly with your QTreeView. If you can see the "child" then the problem is with your GroupSortFilterProxyModel which in your case is located between QTreeView and QStandardItemModel.</p>
]]></description><link>https://forum.qt.io/post/97242</link><guid isPermaLink="true">https://forum.qt.io/post/97242</guid><dc:creator><![CDATA[dakron]]></dc:creator><pubDate>Mon, 11 Jul 2011 08:49:02 GMT</pubDate></item></channel></rss>