[Solved] How to convert TInt(Symbian int type) To QUuid
-
Please tell me how to convert TInt(Symbian int type) To QUuid
I have done the following:
@
QUuid MyApp::Function()
{
TInt Variable=123456;
return QString::number(Variable);
}
@
But the QUuid gets a value 0.[edit: fixed @ tag / chetankjain]
-
QUuid has internal structure (see QUuid::variant()), so, the TInt cannot be the arbitrary value. Details are in the qt documentation for QUuid. Maybe, this will be helpful.
-
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]
-
If you have to use QUuid here, then you will need to write some code that can take an arbitary TInt and convert it to a string of the correct format.
-
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.
-
hi anobika, pls enclose your code within the @ tag.
Also, do post how you went about solving this here :) -
Thanks to one of my colleagues for the solution. Here it is:
@
unsigned int num=7274574;
QUuid uid(0,0,0,0,0,0,0,(num&0xFF000000)>>24,(num&0xFF0000)>>16,(num&0xFF00)>>8,(num&0xFF));
@ -
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.