<?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[[SOLVED]QByteArray values to hex formatted QString]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">I'd like to display QByteArray byte values in my plaintextedit in the following format:</p>
<p dir="auto">00 00 00 .... 00 (20 values per line)<br />
00 00 00 ...  00<br />
..etc</p>
<p dir="auto">I'm using QString::number ( qbytearray[i], 16) but it casts to long/int/uint formats and byte numbers&gt;0x7f show up in the form of ffffffxx (for example if my byte=0xC0 then the output will be  ffffffc0). I'm new to Qt so before I dive into improvised variable manipulations I'd like to ask if there is an easier method provided by Qt libraries. Thank you</p>
]]></description><link>https://forum.qt.io/topic/25145/solved-qbytearray-values-to-hex-formatted-qstring</link><generator>RSS for Node</generator><lastBuildDate>Sun, 14 Jun 2026 16:13:00 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/25145.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 13 Mar 2013 10:28:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED]QByteArray values to hex formatted QString on Wed, 13 Mar 2013 11:05:05 GMT]]></title><description><![CDATA[<p dir="auto">in that case I would check the source of hexdump.<br />
I know it is in C but it gives you an idea how to program that routine quite fast.</p>
]]></description><link>https://forum.qt.io/post/170080</link><guid isPermaLink="true">https://forum.qt.io/post/170080</guid><dc:creator><![CDATA[messi]]></dc:creator><pubDate>Wed, 13 Mar 2013 11:05:05 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED]QByteArray values to hex formatted QString on Wed, 13 Mar 2013 11:00:07 GMT]]></title><description><![CDATA[<p dir="auto">[quote]Did you consider using QByteArray::toHex() for that?[/quote]</p>
<p dir="auto">Andre, thank you for the tip, I came up with a solution using the ::toHex method you suggested.</p>
<p dir="auto">[quote]it sounds to me that you are trying to develop a HexEditor.[/quote]</p>
<p dir="auto">Messi, thank you for your help, I'll check your links later. It is not a hex editor but a simple app which displays the received bytes from the serial port.</p>
<p dir="auto">[quote]I think this would result in the wanted output since you want to interpret it as an unsigned value [/quote]</p>
<p dir="auto">Thank you dvdk.</p>
<p dir="auto"><em>Edit: @ tags are for code sections, not for quoting previous posts; Andre</em></p>
]]></description><link>https://forum.qt.io/post/170078</link><guid isPermaLink="true">https://forum.qt.io/post/170078</guid><dc:creator><![CDATA[JustGreg]]></dc:creator><pubDate>Wed, 13 Mar 2013 11:00:07 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED]QByteArray values to hex formatted QString on Wed, 13 Mar 2013 10:48:27 GMT]]></title><description><![CDATA[<p dir="auto">I think this would result in the wanted output since you want to interpret it as an unsigned value :<br />
@<br />
QString::number ((uchar) qbytearray[i], 16)<br />
@</p>
]]></description><link>https://forum.qt.io/post/170076</link><guid isPermaLink="true">https://forum.qt.io/post/170076</guid><dc:creator><![CDATA[dvdk]]></dc:creator><pubDate>Wed, 13 Mar 2013 10:48:27 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED]QByteArray values to hex formatted QString on Wed, 13 Mar 2013 10:43:47 GMT]]></title><description><![CDATA[<p dir="auto">Hi JustGreg<br />
it sounds to me that you are trying to develop a HexEditor.<br />
If it so, have you checked:<br />
<a href="http://qt-apps.org/content/show.php/QHexEdit?content=133189" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-apps.org/content/show.php/QHexEdit?content=133189</a></p>
<p dir="auto">Anyway, as usual the doc or google is your friend.<br />
google for "qt from int to hex "<br />
Gives you the following result:<br />
<a href="http://qt-project.org/forums/viewthread/7194" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/forums/viewthread/7194</a><br />
<a href="http://www.developer.nokia.com/Community/Wiki/Convert_hexadecimal_to_decimal_and_vice-versa_in_Qt" target="_blank" rel="noopener noreferrer nofollow ugc">http://www.developer.nokia.com/Community/Wiki/Convert_hexadecimal_to_decimal_and_vice-versa_in_Qt</a></p>
]]></description><link>https://forum.qt.io/post/170074</link><guid isPermaLink="true">https://forum.qt.io/post/170074</guid><dc:creator><![CDATA[messi]]></dc:creator><pubDate>Wed, 13 Mar 2013 10:43:47 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED]QByteArray values to hex formatted QString on Wed, 13 Mar 2013 10:43:21 GMT]]></title><description><![CDATA[<p dir="auto">Did you consider using QByteArray::toHex() for that? The result will not be formatted like you are showing, but that should be easy enough to do as a next step.</p>
<p dir="auto"><em>edit</em><br />
Alternatively, you could consider a completely different approach. You could create a custom model operating on your byte array, and use a QTableView to display the values instead.</p>
]]></description><link>https://forum.qt.io/post/170072</link><guid isPermaLink="true">https://forum.qt.io/post/170072</guid><dc:creator><![CDATA[andre]]></dc:creator><pubDate>Wed, 13 Mar 2013 10:43:21 GMT</pubDate></item></channel></rss>