Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QUuid change variant
Qt 6.12 LTS is out! See what's new in the release blog

QUuid change variant

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 485 Views
  • 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.
  • M Offline
    M Offline
    MadBee
    wrote on last edited by
    #1

    Hi!
    I saw in documentation for QUuid have variants. but I didn't get how to generate it.
    if I generate by var = QUuid::createUuid();
    var.variant() - shows '2'
    but how to change it? how to generate uuid with variant 4?
    thanks in advance

    C 1 Reply Last reply
    0
    • M MadBee

      Hi!
      I saw in documentation for QUuid have variants. but I didn't get how to generate it.
      if I generate by var = QUuid::createUuid();
      var.variant() - shows '2'
      but how to change it? how to generate uuid with variant 4?
      thanks in advance

      C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      @MadBee I think you are confusing the UUID variant (DCE, the variant described in RFC 4122) with the UUID version (a sub-type of variant):

      The following table lists the currently-defined versions for this
         UUID variant.
      
         Msb0  Msb1  Msb2  Msb3   Version  Description
      
          0     0     0     1        1     The time-based version
                                           specified in this document.
      
          0     0     1     0        2     DCE Security version, with
                                           embedded POSIX UIDs.
      
          0     0     1     1        3     The name-based version
                                           specified in this document
                                           that uses MD5 hashing.
      
          0     1     0     0        4     The randomly or pseudo-
                                           randomly generated version
                                           specified in this document.
      
          0     1     0     1        5     The name-based version
                                           specified in this document
                                           that uses SHA-1 hashing.
      

      You get a version 4 (random) UUID by default QUuid::createUuid() but there are similar functions to create version 3 and 5 UUIDs. You can construct a QUuid object specifying all the components yourself to obtain a UUID of any variant or version.

      1 Reply Last reply
      1

      • Login

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