Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert QString to Hex?

I have a QString where I append data input from the user.

At the end of the QString, I need to append the hexadecimal representation of a "Normal" QString.

For example:

QString Test("ff00112233440a0a");
QString Input("Words");

Test.append(Input);//but here is where Input needs to be the Hex representation of "Words"

//The resulting variable should be
//Test == "ff00112233440a0a576f726473";

How can I convert from ASCII (I think) to it's Hex representation?

Thanks for your time.

like image 710
mrg95 Avatar asked Nov 23 '25 19:11

mrg95


1 Answers

You were very close:

Test.append(QString::fromLatin1(Input.toLatin1().toHex()));

like image 65
deGoot Avatar answered Nov 26 '25 08:11

deGoot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!