[Solved] How to convert TInt(Symbian int type) To QUuid
-
If you want to create a QUuid based on a QString, then the string must be properly formatted as per the documentation:
http://doc.trolltech.com/4.7/quuid.html#QUuid-3
You cannot convert an arbitrary TInt to a QUuid. I'm not entirely sure what you want to do, but if you want to generate a key based on some arbitrary input, you might want to use MD5 or SHA1 from QCryptographicsHash instead:
-
Hi,
Thanks for your replies..
My code is like below:
@
QUuid QSystemDeviceInfoPrivate::hostId()
{
TInt serialNum;
HAL::Get(HALData::ESerialNumber, serialNum);
return QString::number(serialNum);
}
@
serialNum is the Serial number of this board.[edit: fixed @ tag / chetankjain]
-
UUIDs are 16-byte (128-bit) numbers. TInt seems to be a regular integer of at most 32 bits. You must provide a way to fill up the missing bits. It is not easily possible to convert an int to an UUID. See the "QUuid":http://doc.qt.nokia.com/4.7/quuid.html#details API docs and "Wikipedia":http://en.wikipedia.org/wiki/Universally_Unique_Identifier for some details.
-
This generates an NCS variant UUID. I don't if it is "legal" (i.e. considered a proper way) to construct a UUID this way.
I'd suggest to create a hash based (SHA1) UUID (e.g. with uuidgen on a unix/linux console) and take this as the template for your UUID instead of the 0 fields.