Convert hexadecimal to decimal and vice-versa in Qt
These code snippets shows how to convert hexadecimal to decimal unsigned integer, and vice versa.
Conversion from Hexadecimal to Integer and vice-versa is frequently required in Qt, for example if you want to show UID of application to user then you will get it in uint form, so need to convert in hexadecimal. Similarly when you want to uninstall application silently, then you need to convert hexadecimal to integer, because XQInstaller::remove() method take UID in integer form, not in hexadecimal.
Article Metadata
Hexadecimal to decimal conversion
/* hexadecimal 0xED8788DC is equivavelent to decimal 3985082588 */
QString str = "0xED8788DC";
bool ok;
uint appId = str.toUInt(&ok,16); //appId contains 3985082588
Decimal to hexadecimal conversion
/* decimal 3985082588 is equivalent to hex ED8788DC */
uint decimal = 3985082588;
QString hexadecimal;
haxadecimal.setNum(decimal,16); //now hexadecimal contains ED8788DC
Note: There is a brief overview of how to convert between decimal and hex manually here: how to convert hex to decimal

