<?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[Parsing a hexadecimal data and calculating checksum]]></title><description><![CDATA[<p dir="auto">Hello, I want to first parse a hexadecimal data coming from a device, then calculate the checksum, convert the data to decimal and print it on my screen.<br />
How can ı do that?</p>
]]></description><link>https://forum.qt.io/topic/142623/parsing-a-hexadecimal-data-and-calculating-checksum</link><generator>RSS for Node</generator><lastBuildDate>Fri, 05 Jun 2026 21:44:40 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/142623.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 02 Feb 2023 07:48:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Parsing a hexadecimal data and calculating checksum on Thu, 02 Feb 2023 10:14:40 GMT]]></title><description><![CDATA[<p dir="auto">@J-Hilk said in <a href="/post/745975">Parsing a hexadecimal data and calculating checksum</a>:</p>
<blockquote>
<p dir="auto">I think the OP's question is: "How do I take only 4 Bytes from my QByteArray, so that I can convert it into an int32?"</p>
</blockquote>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> nope, it just exists when the size doesn't match</p>
</blockquote>
<p dir="auto">So if you want to <em>access</em> 4 bytes (<code>sizeof(int32)</code>) for conversion use <a href="https://doc.qt.io/qt-6/qbytearray.html#mid" target="_blank" rel="noopener noreferrer nofollow ugc">QByteArray QByteArray::mid(qsizetype pos, qsizetype len = -1) const</a>.  Otherwise if you want it to appear as an array of <code>int32</code> (and you know byte ordering is correct) use <code>reinterpret_cast&lt;&gt;</code> to int array on the data.</p>
]]></description><link>https://forum.qt.io/post/745987</link><guid isPermaLink="true">https://forum.qt.io/post/745987</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Thu, 02 Feb 2023 10:14:40 GMT</pubDate></item><item><title><![CDATA[Reply to Parsing a hexadecimal data and calculating checksum on Thu, 02 Feb 2023 08:52:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> nope, it just exists when the size doesn't match</p>
<pre><code>auto count = bytes.size();
if (count == 0 || count &gt; 4) {
return 0;
}
</code></pre>
]]></description><link>https://forum.qt.io/post/745981</link><guid isPermaLink="true">https://forum.qt.io/post/745981</guid><dc:creator><![CDATA[J.Hilk]]></dc:creator><pubDate>Thu, 02 Feb 2023 08:52:37 GMT</pubDate></item><item><title><![CDATA[Reply to Parsing a hexadecimal data and calculating checksum on Thu, 02 Feb 2023 08:51:56 GMT]]></title><description><![CDATA[<p dir="auto">@J-Hilk I think byteArrayToUint32 is supposed to do that?</p>
]]></description><link>https://forum.qt.io/post/745980</link><guid isPermaLink="true">https://forum.qt.io/post/745980</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Thu, 02 Feb 2023 08:51:56 GMT</pubDate></item><item><title><![CDATA[Reply to Parsing a hexadecimal data and calculating checksum on Thu, 02 Feb 2023 08:28:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> said in <a href="/post/745973">Parsing a hexadecimal data and calculating checksum</a>:</p>
<blockquote>
<p dir="auto">I don't understand the question.</p>
</blockquote>
<p dir="auto">I think the OP's question is: "How do I take only 4 Bytes from my QByteArray, so that I can convert it into an int32?"</p>
]]></description><link>https://forum.qt.io/post/745975</link><guid isPermaLink="true">https://forum.qt.io/post/745975</guid><dc:creator><![CDATA[J.Hilk]]></dc:creator><pubDate>Thu, 02 Feb 2023 08:28:54 GMT</pubDate></item><item><title><![CDATA[Reply to Parsing a hexadecimal data and calculating checksum on Thu, 02 Feb 2023 08:23:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rumeysa_135">@<bdi>Rumeysa_135</bdi></a> said in <a href="/post/745970">Parsing a hexadecimal data and calculating checksum</a>:</p>
<blockquote>
<p dir="auto">How can I integrate these two codes together?</p>
</blockquote>
<p dir="auto">I don't understand the question.<br />
What do you mean with "integrate"?<br />
Simply call the code where needed.</p>
]]></description><link>https://forum.qt.io/post/745973</link><guid isPermaLink="true">https://forum.qt.io/post/745973</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Thu, 02 Feb 2023 08:23:44 GMT</pubDate></item><item><title><![CDATA[Reply to Parsing a hexadecimal data and calculating checksum on Thu, 02 Feb 2023 07:51:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rumeysa_135">@<bdi>Rumeysa_135</bdi></a> How is this thread different to your older one: <a href="https://forum.qt.io/topic/142574/how-do-i-parse-string-arrays-in-qt">https://forum.qt.io/topic/142574/how-do-i-parse-string-arrays-in-qt</a> ?<br />
You already got some answers there...</p>
]]></description><link>https://forum.qt.io/post/745967</link><guid isPermaLink="true">https://forum.qt.io/post/745967</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Thu, 02 Feb 2023 07:51:29 GMT</pubDate></item><item><title><![CDATA[Reply to Parsing a hexadecimal data and calculating checksum on Thu, 02 Feb 2023 07:50:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rumeysa_135">@<bdi>Rumeysa_135</bdi></a> Use <a href="https://doc.qt.io/qt-6/qstring.html#toInt" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-6/qstring.html#toInt</a> to convert a string containing a hex number to an integer.<br />
Don't know what kind of checksum you need.<br />
"print it on my screen" - can be done using many widgets like QWidget, QTextEdit, ... - depends on how you want to show the data.</p>
]]></description><link>https://forum.qt.io/post/745966</link><guid isPermaLink="true">https://forum.qt.io/post/745966</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Thu, 02 Feb 2023 07:50:49 GMT</pubDate></item></channel></rss>