Reputation:
I am wondering what the most efficient way would be to convert a binary that is saved as a QString into the corresponding Hex and save it in the same QString
QString value = "10111100"
into
value = "bc"
Upvotes: 0
Views: 3569
Reputation: 1494
It's simple. First convert your binary string to an integer:
QString value = "10111100";
bool fOK;
int iValue = value.toInt(&fOk, 2); //2 is the base
Then convert the integer to hex string:
value = QString::number(iValue, 16); //The new base is 16
Upvotes: 1