<?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[Dynamic qml object creation from c++ code]]></title><description><![CDATA[<p dir="auto">I want to strongly separate app logic on c++ and gui on qt quick. I have map (2d array) of cells with deferent properties, which will be modified during app lifecycle. Size of map also can vary. I have cell.qml that describes how cell should look like. But i don't understand how to dynamically create certain amout of cells in qml from cpp code. For example, at initialization, when i create c++ object i need corresponding qml object to be created as well.</p>
]]></description><link>https://forum.qt.io/topic/95258/dynamic-qml-object-creation-from-c-code</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 07:05:34 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/95258.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 Oct 2018 11:09:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dynamic qml object creation from c++ code on Tue, 09 Oct 2018 14:04:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/grecko">@<bdi>GrecKo</bdi></a> You're right! I am defenetly doing some kind of Game of Life)<br />
I've managed to create a map, using GridView and QAbstractListModel like in <a href="https://www.youtube.com/watch?v=9BcAYDlpuT8&amp;feature=youtu.be" target="_blank" rel="noopener noreferrer nofollow ugc">this video</a>.<br />
I also understood how to pass values using model's roles. Now I'm trying to find out how to pass user defined classes through QVariant. I guess i also should register my 'Cell' class with  qmlRegisterType&lt;&gt;</p>
]]></description><link>https://forum.qt.io/post/485955</link><guid isPermaLink="true">https://forum.qt.io/post/485955</guid><dc:creator><![CDATA[FedorKozlov]]></dc:creator><pubDate>Tue, 09 Oct 2018 14:04:06 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamic qml object creation from c++ code on Fri, 05 Oct 2018 15:14:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/fedorkozlov">@<bdi>FedorKozlov</bdi></a> There's no need for a DelegateModel in your case.</p>
<p dir="auto">You can display table data with a <code>TableView</code>, but you can also display data in a table like fashion with a <code>GridView</code> or even a <code>Repeater</code> with the delegates positionning themselves.</p>
<p dir="auto">If I guessed right you are trying to do some kind of Game of Life in Qt Quick.<br />
The position of your cells is just data, you don't really need a table model.</p>
]]></description><link>https://forum.qt.io/post/485428</link><guid isPermaLink="true">https://forum.qt.io/post/485428</guid><dc:creator><![CDATA[GrecKo]]></dc:creator><pubDate>Fri, 05 Oct 2018 15:14:49 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamic qml object creation from c++ code on Fri, 05 Oct 2018 14:51:22 GMT]]></title><description><![CDATA[<p dir="auto">Thank you all for your answers!</p>
<p dir="auto">I believe as <a class="plugin-mentions-user plugin-mentions-a" href="/user/grecko">@<bdi>GrecKo</bdi></a> said QAbstractItemModel is what i really need.<br />
Though, as i found here <a href="http://doc.qt.io/qt-5/qtquick-modelviewsdata-cppmodels.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qtquick-modelviewsdata-cppmodels.html</a><br />
QAbstractItemModel presents a hierarchy of tables, but the views currently provided by QML can only display list data. In order to display the child lists of a hierarchical model, use the DelegateModel QML type</p>
]]></description><link>https://forum.qt.io/post/485422</link><guid isPermaLink="true">https://forum.qt.io/post/485422</guid><dc:creator><![CDATA[FedorKozlov]]></dc:creator><pubDate>Fri, 05 Oct 2018 14:51:22 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamic qml object creation from c++ code on Thu, 04 Oct 2018 15:14:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/fedorkozlov">@<bdi>FedorKozlov</bdi></a><br />
It's much easier to do QML tasks in QML.  Create a QML method to do it and call it from C++ with  QMetaObject::invokeMethod().</p>
]]></description><link>https://forum.qt.io/post/485244</link><guid isPermaLink="true">https://forum.qt.io/post/485244</guid><dc:creator><![CDATA[Tom_H]]></dc:creator><pubDate>Thu, 04 Oct 2018 15:14:57 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamic qml object creation from c++ code on Thu, 04 Oct 2018 13:07:08 GMT]]></title><description><![CDATA[<p dir="auto">For your usecase you should expose a QAbstractItemModel to your QML layer.<br />
Then in QML you would use a <code>Repeater</code> that will instantiate a <code>Cell</code> for each row of your model.</p>
]]></description><link>https://forum.qt.io/post/485222</link><guid isPermaLink="true">https://forum.qt.io/post/485222</guid><dc:creator><![CDATA[GrecKo]]></dc:creator><pubDate>Thu, 04 Oct 2018 13:07:08 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamic qml object creation from c++ code on Thu, 04 Oct 2018 11:32:18 GMT]]></title><description><![CDATA[<p dir="auto">Hello @FedorKozlov.</p>
<p dir="auto">From my point of view, if you want to trigger an action from the c++ side to qml side, you must use the signal/slot mechanism. Otherwise, you should have the object of your c++ class in qml, and if the user triggers an event, you provide a method to respond that action if it is required backend activity.</p>
<p dir="auto">If you provide some code it would nice, your explication it is kind of abstract.</p>
]]></description><link>https://forum.qt.io/post/485173</link><guid isPermaLink="true">https://forum.qt.io/post/485173</guid><dc:creator><![CDATA[oria66]]></dc:creator><pubDate>Thu, 04 Oct 2018 11:32:18 GMT</pubDate></item></channel></rss>