<?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[Hot to convert (cast) QHash&lt;int, StructOfQByteArray1AndQbyteArray2&gt; to QHash&lt;int, QByteArray1&gt; with minimum resource cost?]]></title><description><![CDATA[<p dir="auto">ok. let's find out how well do you know C++.<br />
ok we have</p>
<pre><code>struct StructOfQByteArray1AndQbyteArray2 {
    QByteArray array1;
    QByteArray array2;
}
</code></pre>
<p dir="auto">Hot to convert (cast) <code>QHash&lt;int, StructOfQByteArray1AndQbyteArray2&gt;</code> to <code>QHash&lt;int, QByteArray1&gt;</code> with minimum resource cost?</p>
<p dir="auto">where I want to use this?<br />
when working with <code>QAbstractItemModel</code> I implement method <code>QHash&lt;int, QByteArray&gt; QAbstractItemModel::roleNames() const</code> but in app I have more complex <code>QHash&lt;int, StructOfQByteArray1AndQbyteArray2&gt;</code> with some extra data.</p>
]]></description><link>https://forum.qt.io/topic/70207/hot-to-convert-cast-qhash-int-structofqbytearray1andqbytearray2-to-qhash-int-qbytearray1-with-minimum-resource-cost</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 09:42:27 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/70207.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 13 Aug 2016 12:49:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hot to convert (cast) QHash&lt;int, StructOfQByteArray1AndQbyteArray2&gt; to QHash&lt;int, QByteArray1&gt; with minimum resource cost? on Thu, 18 Aug 2016 20:09:36 GMT]]></title><description><![CDATA[<p dir="auto">Ok  but these roles are already known, no ?</p>
]]></description><link>https://forum.qt.io/post/343066</link><guid isPermaLink="true">https://forum.qt.io/post/343066</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 18 Aug 2016 20:09:36 GMT</pubDate></item><item><title><![CDATA[Reply to Hot to convert (cast) QHash&lt;int, StructOfQByteArray1AndQbyteArray2&gt; to QHash&lt;int, QByteArray1&gt; with minimum resource cost? on Thu, 18 Aug 2016 18:55:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> yes, I will have custom roles for some delegates.</p>
]]></description><link>https://forum.qt.io/post/343054</link><guid isPermaLink="true">https://forum.qt.io/post/343054</guid><dc:creator><![CDATA[Kofr]]></dc:creator><pubDate>Thu, 18 Aug 2016 18:55:47 GMT</pubDate></item><item><title><![CDATA[Reply to Hot to convert (cast) QHash&lt;int, StructOfQByteArray1AndQbyteArray2&gt; to QHash&lt;int, QByteArray1&gt; with minimum resource cost? on Sun, 14 Aug 2016 19:02:47 GMT]]></title><description><![CDATA[<p dir="auto">I'm just saying that you can't cast (as in static_cast, dynamic_cast etc.) such a hash of int and struct to a hash of int and QByteArray.</p>
<p dir="auto">Are your role names going to be dynamically created ? Changed ?</p>
]]></description><link>https://forum.qt.io/post/342267</link><guid isPermaLink="true">https://forum.qt.io/post/342267</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 14 Aug 2016 19:02:47 GMT</pubDate></item><item><title><![CDATA[Reply to Hot to convert (cast) QHash&lt;int, StructOfQByteArray1AndQbyteArray2&gt; to QHash&lt;int, QByteArray1&gt; with minimum resource cost? on Sun, 14 Aug 2016 08:15:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> Speed. So you want to say that it is ok to manually fill in <code>QHash&lt;int, QByteArray&gt;</code> before returning and just allow data to be copied as rvalue?</p>
]]></description><link>https://forum.qt.io/post/342222</link><guid isPermaLink="true">https://forum.qt.io/post/342222</guid><dc:creator><![CDATA[Kofr]]></dc:creator><pubDate>Sun, 14 Aug 2016 08:15:01 GMT</pubDate></item><item><title><![CDATA[Reply to Hot to convert (cast) QHash&lt;int, StructOfQByteArray1AndQbyteArray2&gt; to QHash&lt;int, QByteArray1&gt; with minimum resource cost? on Sat, 13 Aug 2016 18:30:17 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">From a C++ POV: you can't do such a cast.</p>
<p dir="auto">What resources do you want to optimize ? Speed ? Memory use ?</p>
]]></description><link>https://forum.qt.io/post/342204</link><guid isPermaLink="true">https://forum.qt.io/post/342204</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sat, 13 Aug 2016 18:30:17 GMT</pubDate></item><item><title><![CDATA[Reply to Hot to convert (cast) QHash&lt;int, StructOfQByteArray1AndQbyteArray2&gt; to QHash&lt;int, QByteArray1&gt; with minimum resource cost? on Sat, 13 Aug 2016 13:36:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kofr">@<bdi>Kofr</bdi></a> said:</p>
<p dir="auto">ahh its something you must return.</p>
<p dir="auto">Well i think u need copy then since i doubt there is way to cast the original<br />
StructOfQByteArray1AndQbyteArray2</p>
]]></description><link>https://forum.qt.io/post/342166</link><guid isPermaLink="true">https://forum.qt.io/post/342166</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Sat, 13 Aug 2016 13:36:24 GMT</pubDate></item><item><title><![CDATA[Reply to Hot to convert (cast) QHash&lt;int, StructOfQByteArray1AndQbyteArray2&gt; to QHash&lt;int, QByteArray1&gt; with minimum resource cost? on Sat, 13 Aug 2016 13:27:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> but I have to return exactly data, not pointer <code>QHash&lt;int, QByteArray&gt; QAbstractItemModel::roleNames() const</code></p>
]]></description><link>https://forum.qt.io/post/342164</link><guid isPermaLink="true">https://forum.qt.io/post/342164</guid><dc:creator><![CDATA[Kofr]]></dc:creator><pubDate>Sat, 13 Aug 2016 13:27:15 GMT</pubDate></item><item><title><![CDATA[Reply to Hot to convert (cast) QHash&lt;int, StructOfQByteArray1AndQbyteArray2&gt; to QHash&lt;int, QByteArray1&gt; with minimum resource cost? on Sat, 13 Aug 2016 12:54:52 GMT]]></title><description><![CDATA[<p dir="auto">well if u want to avoid copy bytearray<br />
maybe use something like<br />
QHash&lt;int, QByteArray1 *&gt;<br />
and set to point to the real QByteArray1; ?</p>
]]></description><link>https://forum.qt.io/post/342161</link><guid isPermaLink="true">https://forum.qt.io/post/342161</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Sat, 13 Aug 2016 12:54:52 GMT</pubDate></item></channel></rss>