<?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[QList of C++ custom objects to QML]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">Here is my need. I am reading an XML file in the C++ side of my application, and create some C++ objects of mine. After the reading, I send a signal to the QML to tell my GUI it has some QML components to dynamically instanciates.<br />
I want those components to be initialized with the properties of the C++ objects I have created during the reading of the XML file.<br />
So the idea here is to send a list of C++ objects to the QML, and parse that list inside the QML to create components.<br />
I had a look at the QVariant class, but don't really know how to use it.<br />
For example, I currently have a <code>QList&lt;MyObjects*&gt;</code> that I want to expose to the QML via a Q_INVOKABLE method.<br />
How do I do that? Does a <code>QList&lt;QVariant*&gt;</code> will be enought?</p>
<p dir="auto">Regards,</p>
]]></description><link>https://forum.qt.io/topic/71657/qlist-of-c-custom-objects-to-qml</link><generator>RSS for Node</generator><lastBuildDate>Tue, 14 Apr 2026 14:39:13 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/71657.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 27 Sep 2016 09:37:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QList of C++ custom objects to QML on Wed, 28 Sep 2016 09:45:13 GMT]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">Ok thanks for this additional explanation.<br />
I'll give it a try and let you know if I face some difficulties.</p>
<p dir="auto">Regards</p>
]]></description><link>https://forum.qt.io/post/350476</link><guid isPermaLink="true">https://forum.qt.io/post/350476</guid><dc:creator><![CDATA[bguivarch]]></dc:creator><pubDate>Wed, 28 Sep 2016 09:45:13 GMT</pubDate></item><item><title><![CDATA[Reply to QList of C++ custom objects to QML on Tue, 27 Sep 2016 09:50:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bguivarch">@<bdi>bguivarch</bdi></a> said in <a href="/post/350165">QList of C++ custom objects to QML</a>:</p>
<blockquote>
<p dir="auto">With my understanding of QML, I would say that I have to.</p>
</blockquote>
<p dir="auto">exactly, since QML uses the meta type system.</p>
]]></description><link>https://forum.qt.io/post/350167</link><guid isPermaLink="true">https://forum.qt.io/post/350167</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Tue, 27 Sep 2016 09:50:34 GMT</pubDate></item><item><title><![CDATA[Reply to QList of C++ custom objects to QML on Tue, 27 Sep 2016 09:47:38 GMT]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">Thanks for your answer.</p>
<p dir="auto">To access the properties of the objects in the list, do I have to convert these properties to <code>Q_PROPERTY</code> or is that unnecessary? With my understanding of QML, I would say that I have to.</p>
<p dir="auto">Regards</p>
]]></description><link>https://forum.qt.io/post/350165</link><guid isPermaLink="true">https://forum.qt.io/post/350165</guid><dc:creator><![CDATA[bguivarch]]></dc:creator><pubDate>Tue, 27 Sep 2016 09:47:38 GMT</pubDate></item><item><title><![CDATA[Reply to QList of C++ custom objects to QML on Tue, 27 Sep 2016 09:42:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bguivarch">@<bdi>bguivarch</bdi></a> said in <a href="/post/350160">QList of C++ custom objects to QML</a>:</p>
<blockquote>
<p dir="auto">How do I do that? Does a QList&lt;QVariant*&gt; will be enought?</p>
</blockquote>
<p dir="auto">Yes. But use <code>QList&lt;QVariant&gt;</code> instead. When you registered the list contents (in the variant) to the meta type system (<code>Q_DECLARE_METATYPE</code>) you can access it's QObject properties from QML.</p>
]]></description><link>https://forum.qt.io/post/350163</link><guid isPermaLink="true">https://forum.qt.io/post/350163</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Tue, 27 Sep 2016 09:42:37 GMT</pubDate></item></channel></rss>