<?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[Custom Model in defined TreeView in Designer]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I'm new on QT and i'm trying to use the <a href="http://doc.qt.io/qt-5/qtwidgets-itemviews-simpletreemodel-example.html" target="_blank" rel="noopener noreferrer nofollow ugc">SimpleTreeModel</a> in a Designer defined TreeView.</p>
<p dir="auto">My TreeView is set as "cardView".</p>
<p dir="auto">But it isn't shown.</p>
<pre><code>QFile file(":/dateien/default.txt"); 
file.open(QIODevice::ReadOnly); 
cardViewModel model(file.readAll()); 
file.close(); 
ui-&gt;cardView-&gt;setModel(&amp;model);
</code></pre>
<p dir="auto">Everyting is the same like in the example, i just changed the names of TreeView and TreeItem as following;</p>
<p dir="auto">TreeItem -&gt; cardViewItem<br />
TreeModel -&gt; cardViewModel</p>
]]></description><link>https://forum.qt.io/topic/58774/custom-model-in-defined-treeview-in-designer</link><generator>RSS for Node</generator><lastBuildDate>Thu, 11 Jun 2026 01:01:23 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/58774.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 10 Sep 2015 23:45:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Custom Model in defined TreeView in Designer on Fri, 11 Sep 2015 11:48:49 GMT]]></title><description><![CDATA[<p dir="auto">Thank you now it's working.</p>
<p dir="auto">Now i'm getting the following</p>
<p dir="auto">QStringList columnStrings = lineData.split("|");<br />
QList&lt;QVariant&gt; columnData;</p>
<p dir="auto">how can I now check if the columnData starts with a '#' and define it as root and if not define it as child of</p>
]]></description><link>https://forum.qt.io/post/289963</link><guid isPermaLink="true">https://forum.qt.io/post/289963</guid><dc:creator><![CDATA[Rocky]]></dc:creator><pubDate>Fri, 11 Sep 2015 11:48:49 GMT</pubDate></item><item><title><![CDATA[Reply to Custom Model in defined TreeView in Designer on Fri, 11 Sep 2015 04:23:59 GMT]]></title><description><![CDATA[<p dir="auto">If you make cardViewModel member of the class then there is no need to make it a pointer and allocate it on the heap.</p>
]]></description><link>https://forum.qt.io/post/289926</link><guid isPermaLink="true">https://forum.qt.io/post/289926</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Fri, 11 Sep 2015 04:23:59 GMT</pubDate></item><item><title><![CDATA[Reply to Custom Model in defined TreeView in Designer on Fri, 11 Sep 2015 00:28:03 GMT]]></title><description><![CDATA[<p dir="auto">No it is not the same.</p>
<p dir="auto">Example instantiate both model and view in the main.<br />
This means they both exist until application (main) exits.</p>
<p dir="auto">It looks like you are doing it in one of the function of the class created by designer (likely constructor).<br />
When you create object on the stack it is deleted when it goes out of scope.<br />
So cardViewModel model gets deleted.</p>
<p dir="auto">You probably want to add cardViewModel * model member to the class, allocate it on the heap, pass the poi9nter to view and destroy in the constructor.</p>
]]></description><link>https://forum.qt.io/post/289920</link><guid isPermaLink="true">https://forum.qt.io/post/289920</guid><dc:creator><![CDATA[alex_malyu]]></dc:creator><pubDate>Fri, 11 Sep 2015 00:28:03 GMT</pubDate></item></channel></rss>