How to convert decimal to hexadecimal with Qt programming? Such as 69 switch to 45, 56 switch to 38 and so on... I try like this
QString str = QString::number(s.at(i).unicode());
bool ok;
qDebug() << str.toUtf8();
but failed. I need to convert this string "E8A5" ASCII switch to hexadecimal number or string.
Source string:
QString str = QString::number(s.at(i).unicode());
Then:
Step 1. Convert string to integer
int nValue = str.toInt();
Step 2. Convert integer back to Hex string, using Qt
QString result = QString::number( nValue, 16 );
Step 3. Convert to uppercase (optional)
qDebug() << result.toUpper();
or all together in shorter form:
qDebug() << QString::number( str.toInt(), 16 ).toUpper();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With