<?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[How can I copy one QByteArray at n-index of another QByteArray?]]></title><description><![CDATA[<p dir="auto">Say I have two QByteArrays: one <strong>(a)</strong> at 136 bytes, and the other <strong>(b)</strong> at 128 bytes. I want to copy the entirety of <strong>(b)</strong> starting at <strong>(a)</strong>[6]. Is that possible, or would I have to do something like: <code>(a) = (a).mid(0, 6) + (b) + (a).mid(133, 2)</code>?</p>
]]></description><link>https://forum.qt.io/topic/82184/how-can-i-copy-one-qbytearray-at-n-index-of-another-qbytearray</link><generator>RSS for Node</generator><lastBuildDate>Fri, 12 Jun 2026 05:17:09 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/82184.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 09 Aug 2017 09:22:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How can I copy one QByteArray at n-index of another QByteArray? on Wed, 09 Aug 2017 10:07:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/wost">@<bdi>wost</bdi></a> said in <a href="/post/409306">How can I copy one QByteArray at n-index of another QByteArray?</a>:</p>
<blockquote>
<p dir="auto">Will that work with readyRead? I'm getting the data through a QSerialPort.</p>
</blockquote>
<p dir="auto">so how do you ensure that you have already received the whole data you are looking for?</p>
]]></description><link>https://forum.qt.io/post/409309</link><guid isPermaLink="true">https://forum.qt.io/post/409309</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Wed, 09 Aug 2017 10:07:03 GMT</pubDate></item><item><title><![CDATA[Reply to How can I copy one QByteArray at n-index of another QByteArray? on Wed, 09 Aug 2017 10:02:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/wost">@<bdi>wost</bdi></a></p>
<pre><code>    QByteArray *arr = new QByteArray("abcd");

    QByteArray *arr2 = new QByteArray("efgh");

    QByteArray *arr3 = new QByteArray((QByteArray)(arr-&gt;mid(0, 2) + arr2-&gt;mid(0,3)));

    qDebug() &lt;&lt; QString::fromStdString(arr3-&gt;toStdString()); = "abefg"
</code></pre>
]]></description><link>https://forum.qt.io/post/409307</link><guid isPermaLink="true">https://forum.qt.io/post/409307</guid><dc:creator><![CDATA[Taz742]]></dc:creator><pubDate>Wed, 09 Aug 2017 10:02:40 GMT</pubDate></item><item><title><![CDATA[Reply to How can I copy one QByteArray at n-index of another QByteArray? on Wed, 09 Aug 2017 09:59:50 GMT]]></title><description><![CDATA[<p dir="auto">Will that work with readyRead? I'm getting the data through a QSerialPort.<br />
Doing this: <code>_frame = _frame.left(6) + _states + _frame.right(2);</code> worked, but I'm not sure if this is the best way to do it.</p>
]]></description><link>https://forum.qt.io/post/409306</link><guid isPermaLink="true">https://forum.qt.io/post/409306</guid><dc:creator><![CDATA[wost]]></dc:creator><pubDate>Wed, 09 Aug 2017 09:59:50 GMT</pubDate></item><item><title><![CDATA[Reply to How can I copy one QByteArray at n-index of another QByteArray? on Wed, 09 Aug 2017 09:52:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/wost">@<bdi>wost</bdi></a><br />
when you use <code>QDataStream</code> for reading and writing the nested QByteArray data, Qt takes care of all for you.<br />
So that the nested QByteArrays have the correct size after reading them out again.</p>
]]></description><link>https://forum.qt.io/post/409304</link><guid isPermaLink="true">https://forum.qt.io/post/409304</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Wed, 09 Aug 2017 09:52:45 GMT</pubDate></item></channel></rss>