<?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 expand icon change when changing model]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I have a custom QTreeWidget where i have defined my own setModel method (to add QTableView in child item)</p>
<p dir="auto">When i refresh the model, the expand icon change. The first time it's an arrow icon but when i set the model a second time, the expand icon is now a plus or minus icon.</p>
<p dir="auto">Where does that icon change come from ? (I can post code for more details)</p>
<p dir="auto">Thx</p>
]]></description><link>https://forum.qt.io/topic/69722/qtreewidget-expand-icon-change-when-changing-model</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 15:31:12 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/69722.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 28 Jul 2016 13:00:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QTreeWidget expand icon change when changing model on Mon, 01 Aug 2016 12:44:00 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> and thx for the reply,</p>
<p dir="auto">I'm using a QTableView in a QTreeWidget.</p>
<p dir="auto">Here is my code (refresh part) :</p>
<pre><code>// window.cpp
void refresh(){
        this-&gt;cordonDAO-&gt;refreshData(this-&gt;commande-&gt;getNumAffaire());
        this-&gt;treeWidgetCustom-&gt;setModel(cordonDAO-&gt;getModelCordonParent(), cordonDAO-&gt;getListeModel());
}

// customQTreeWidget.cpp

void CustomQTreeWidget::setModel(QSqlQueryModel* modelParent, QMap&lt;QString,QSqlQueryModel*&gt;* modelFils){
    this-&gt;clear();
    for(int i=0;i&lt;modelParent-&gt;rowCount();i++){
        QString refCordon=modelParent-&gt;data(modelParent-&gt;index(i,0)).toString();
        QString qte=modelParent-&gt;data(modelParent-&gt;index(i,1)).toString();
        QTreeWidgetItem* item=new QTreeWidgetItem(this,QStringList() &lt;&lt; refCordon &lt;&lt; qte);
        item-&gt;setFlags(Qt::ItemIsEnabled);
        this-&gt;addTopLevelItem(item);
        QTableView* table=new QTableView();
        table-&gt;setModel(modelFils-&gt;value(refCordon));
        setTableUI(table);
        QTreeWidgetItem* childItem=new QTreeWidgetItem(item);
        this-&gt;setItemWidget(childItem,1,table);
        item-&gt;addChild(childItem);
        connect(table,SIGNAL(doubleClicked(QModelIndex)),(secondwindow*)(this-&gt;parentWidget()-&gt;parentWidget()),SLOT(tableDoubleClicked(QModelIndex)));
    }
}
</code></pre>
<p dir="auto">The QSqlQueryModel is for the TreeWidget, and the QMap contains the QSqlQueryModel for each TableWidget of the TreeWidget.</p>
<p dir="auto">Here is the result before refresh :<br />
<img src="http://img4.hostingpics.net/pics/668651avant.jpg" alt="alt text" title="before" class=" img-fluid img-markdown" /></p>
<p dir="auto">And after :<br />
<img src="http://img4.hostingpics.net/pics/779101apres.jpg" alt="alt text" title="after" class=" img-fluid img-markdown" /></p>
<p dir="auto">I found a bug report that is exactly the same problem : <a href="https://bugreports.qt.io/browse/QTBUG-53310" target="_blank" rel="noopener noreferrer nofollow ugc">QT bug</a></p>
<p dir="auto">Thx</p>
]]></description><link>https://forum.qt.io/post/340209</link><guid isPermaLink="true">https://forum.qt.io/post/340209</guid><dc:creator><![CDATA[Zoptune]]></dc:creator><pubDate>Mon, 01 Aug 2016 12:44:00 GMT</pubDate></item><item><title><![CDATA[Reply to QTreeWidget expand icon change when changing model on Thu, 28 Jul 2016 21:49:38 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Yes you should post your code.</p>
<p dir="auto">One thing that's strange: are you really using QTableWidget ? Because it already has a model and IIRC you can't change it.</p>
]]></description><link>https://forum.qt.io/post/339821</link><guid isPermaLink="true">https://forum.qt.io/post/339821</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 28 Jul 2016 21:49:38 GMT</pubDate></item></channel></rss>