Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.
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.
Hexadecimal to decimal conversion
/* hexadecimal 0xED8788DC is equivavelent to decimal 3985082588 */
QString str = "0xED8788DC";
uint appId = str.toUInt(&ok,16); //appId contains 3985082588
Decimal to hexadecimal conversion
/* decimal 3985082588 is equivalent to hex ED8788DC */
uint decimal = 3985082588;
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