<?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 itemModel, passing &quot;complex variant&quot; from QML]]></title><description><![CDATA[<p dir="auto">I have a custom  item model extending QAbstractItemModel and Implementing setData method. On the QML I can assign data to roleNames and the setData method gets called correctly with the QVariant instance but only if the data is a basic type. Is there a way to pass a QVariantMap from QML to C++ through setData?</p>
<p dir="auto">Example in QML:<br />
rolename = "string"  //works fine<br />
rolename = {key : "value"} //does not work (QVariant is empty on c++ side)<br />
rolename = {"key" : "value"} //does not work (QVariant is empty on c++ side)</p>
]]></description><link>https://forum.qt.io/topic/78668/custom-itemmodel-passing-complex-variant-from-qml</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Apr 2026 14:43:18 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/78668.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 27 Apr 2017 08:47:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Custom itemModel, passing &quot;complex variant&quot; from QML on Tue, 02 May 2017 06:13:55 GMT]]></title><description><![CDATA[<p dir="auto">Thanks, that worked perfectly.</p>
<p dir="auto">My error was trying to convert the Variant to a JsonObject instead of a VariantMap on the c++ side.</p>
]]></description><link>https://forum.qt.io/post/391064</link><guid isPermaLink="true">https://forum.qt.io/post/391064</guid><dc:creator><![CDATA[Fede Devi]]></dc:creator><pubDate>Tue, 02 May 2017 06:13:55 GMT</pubDate></item><item><title><![CDATA[Reply to Custom itemModel, passing &quot;complex variant&quot; from QML on Fri, 28 Apr 2017 17:35:19 GMT]]></title><description><![CDATA[<p dir="auto">setData uses QVariant as argument probably you need to convert to QVarianMap using QVariant::toMap on c++ side</p>
]]></description><link>https://forum.qt.io/post/390581</link><guid isPermaLink="true">https://forum.qt.io/post/390581</guid><dc:creator><![CDATA[PhlipVR]]></dc:creator><pubDate>Fri, 28 Apr 2017 17:35:19 GMT</pubDate></item></channel></rss>