<?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] Populate a QML ListView with a custom C++ model]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I have a custom Model representing a tree based on this example:<br />
<a href="http://qt-project.org/doc/qt-5/qtwidgets-itemviews-simpletreemodel-example.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-5/qtwidgets-itemviews-simpletreemodel-example.html</a></p>
<p dir="auto">My internal model is correctly populated and I can manually output it to console to check that it works perfectly.</p>
<p dir="auto">In the QML, I do something like:<br />
@  ListView<br />
{<br />
id: sceneGraphView<br />
anchors.fill: parent</p>
<pre><code>model: sceneGraphModel
delegate: sceneNodeDelegate
</code></pre>
<p dir="auto">}@</p>
<p dir="auto">Unfortunately, I only get the first element of my model. Is this the correct way to populate a ListView?</p>
<p dir="auto">Also, the model's methods called when I launch the application are:<br />
@rowCount<br />
roleNames<br />
index<br />
rowCount<br />
columnCount<br />
data @</p>
<p dir="auto">Thanks for any help.</p>
]]></description><link>https://forum.qt.io/topic/39254/solved-populate-a-qml-listview-with-a-custom-c-model</link><generator>RSS for Node</generator><lastBuildDate>Sun, 25 Oct 2026 04:40:15 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/39254.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 Mar 2014 09:16:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED] Populate a QML ListView with a custom C++ model on Fri, 21 Mar 2014 09:33:49 GMT]]></title><description><![CDATA[<p dir="auto">Ok, I see. Thanks a lot for your help!</p>
]]></description><link>https://forum.qt.io/post/219360</link><guid isPermaLink="true">https://forum.qt.io/post/219360</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 21 Mar 2014 09:33:49 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Populate a QML ListView with a custom C++ model on Fri, 21 Mar 2014 04:49:50 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Currently there's no of Treeview for QML. But there are some work around's<br />
For eg. See "this":<a href="http://qt-project.org/forums/viewthread/30521/#136940" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/forums/viewthread/30521/#136940</a></p>
]]></description><link>https://forum.qt.io/post/219332</link><guid isPermaLink="true">https://forum.qt.io/post/219332</guid><dc:creator><![CDATA[p3c0]]></dc:creator><pubDate>Fri, 21 Mar 2014 04:49:50 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Populate a QML ListView with a custom C++ model on Thu, 20 Mar 2014 16:42:37 GMT]]></title><description><![CDATA[<p dir="auto">Ok, it seems that the QML View I use is not appropriate for that. When testing with a QTreeView, it worked immediately. What QML view should I use then to display a Tree in QML? it seems that none are present for the moment.</p>
<p dir="auto">Thanks for any help.</p>
]]></description><link>https://forum.qt.io/post/219250</link><guid isPermaLink="true">https://forum.qt.io/post/219250</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Thu, 20 Mar 2014 16:42:37 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Populate a QML ListView with a custom C++ model on Thu, 20 Mar 2014 14:57:08 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for your answer.</p>
<p dir="auto">The model is already populated when the view access it the first time calling rowCount.</p>
<p dir="auto">My main concern is about the C++ model members called from the QML ListView. I am not sure it is correct and sufficient.</p>
<p dir="auto">Best regards.</p>
]]></description><link>https://forum.qt.io/post/219238</link><guid isPermaLink="true">https://forum.qt.io/post/219238</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Thu, 20 Mar 2014 14:57:08 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Populate a QML ListView with a custom C++ model on Thu, 20 Mar 2014 09:31:57 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Are you calling "beginInsertRows":<a href="https://qt-project.org/doc/qt-5.1/qtcore/qabstractitemmodel.html#beginInsertRows" target="_blank" rel="noopener noreferrer nofollow ugc">https://qt-project.org/doc/qt-5.1/qtcore/qabstractitemmodel.html#beginInsertRows</a> and "endInsertRows":<a href="https://qt-project.org/doc/qt-5.1/qtcore/qabstractitemmodel.html#endInsertRows" target="_blank" rel="noopener noreferrer nofollow ugc">https://qt-project.org/doc/qt-5.1/qtcore/qabstractitemmodel.html#endInsertRows</a> when populating the list ?<br />
See "this":<a href="https://qt-project.org/doc/qt-5.1/qtquick/qtquick-modelviewsdata-cppmodels.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://qt-project.org/doc/qt-5.1/qtquick/qtquick-modelviewsdata-cppmodels.html</a> example for how to use C++ model in QML</p>
]]></description><link>https://forum.qt.io/post/219187</link><guid isPermaLink="true">https://forum.qt.io/post/219187</guid><dc:creator><![CDATA[p3c0]]></dc:creator><pubDate>Thu, 20 Mar 2014 09:31:57 GMT</pubDate></item></channel></rss>