Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [Solved] How to convert TInt(Symbian int type) To QUuid
Forum Updated to NodeBB v4.3 + New Features

[Solved] How to convert TInt(Symbian int type) To QUuid

Scheduled Pinned Locked Moved Mobile and Embedded
9 Posts 4 Posters 5.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    anobika
    wrote on last edited by
    #1

    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]

    1 Reply Last reply
    0
    • B Offline
      B Offline
      blex
      wrote on last edited by
      #2

      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.


      Oleksiy Balabay

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jbarron
        wrote on last edited by
        #3

        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:

        http://doc.trolltech.com/4.7/qcryptographichash.html

        1 Reply Last reply
        0
        • A Offline
          A Offline
          anobika
          wrote on last edited by
          #4

          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]

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jbarron
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #6

              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.

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • ? This user is from outside of this forum
                ? This user is from outside of this forum
                Guest
                wrote on last edited by
                #7

                hi anobika, pls enclose your code within the @ tag.
                Also, do post how you went about solving this here :)

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  anobika
                  wrote on last edited by
                  #8

                  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));
                  @

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #9

                    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.

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved