<?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[QtQuick2: QAbstractListModel - passing object from C++ to QML [SOLVED]]]></title><description><![CDATA[<p dir="auto">Hello.<br />
I have a project, which is well working in Qt 4.8, but I need to port it to the new version of Qt - 5.1.</p>
<ol>
<li>I have a class CControl derived from QObject and having a few properties defined by Q_PROPERTY macro. It is registered wit qmlRegisterType.</li>
<li>I have the CListModel class, which derives from QAbstractListModel and from QList&lt;CControl*&gt; and I'm using it to pass data for the list defined in QML.</li>
<li>I have defined a role ItemRole (named item).</li>
<li>When I access it from QML, I just pass (in data() method) my CControl object like this:<br />
@return QVariant::fromValue&lt;CControl*&gt;(ctrl);@</li>
</ol>
<p dir="auto">When I try to access the ItemRole from QML like this:<br />
@property CControl control: item@</p>
<p dir="auto">I get an error: <em>Unable to assign ObjectsList_QMLTYPE_102 to CControl.</em></p>
]]></description><link>https://forum.qt.io/topic/32134/qtquick2-qabstractlistmodel-passing-object-from-c-to-qml-solved</link><generator>RSS for Node</generator><lastBuildDate>Thu, 19 Nov 2026 05:05:51 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/32134.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 19 Sep 2013 06:15:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QtQuick2: QAbstractListModel - passing object from C++ to QML [SOLVED] on Mon, 23 Sep 2013 13:59:50 GMT]]></title><description><![CDATA[<p dir="auto">Please add [SOLVED] to your thread title.</p>
]]></description><link>https://forum.qt.io/post/196397</link><guid isPermaLink="true">https://forum.qt.io/post/196397</guid><dc:creator><![CDATA[messi]]></dc:creator><pubDate>Mon, 23 Sep 2013 13:59:50 GMT</pubDate></item><item><title><![CDATA[Reply to QtQuick2: QAbstractListModel - passing object from C++ to QML [SOLVED] on Thu, 19 Sep 2013 07:33:12 GMT]]></title><description><![CDATA[<p dir="auto">The one who asked for the solution, gave answer. Thats cool :)</p>
]]></description><link>https://forum.qt.io/post/195859</link><guid isPermaLink="true">https://forum.qt.io/post/195859</guid><dc:creator><![CDATA[kumararajas]]></dc:creator><pubDate>Thu, 19 Sep 2013 07:33:12 GMT</pubDate></item><item><title><![CDATA[Reply to QtQuick2: QAbstractListModel - passing object from C++ to QML [SOLVED] on Thu, 19 Sep 2013 07:17:40 GMT]]></title><description><![CDATA[<p dir="auto">Sorry, my fault. I have commented setRoleNames() at the beginning of porting as it was not compiling :)<br />
Just overriden roleNames and it's fine now.</p>
]]></description><link>https://forum.qt.io/post/195858</link><guid isPermaLink="true">https://forum.qt.io/post/195858</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Thu, 19 Sep 2013 07:17:40 GMT</pubDate></item></channel></rss>