Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Time stamp with microsecond resolution
Qt 6.11 is out! See what's new in the release blog

Time stamp with microsecond resolution

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 3.4k 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.
  • V Offline
    V Offline
    valeria70
    wrote on last edited by
    #1

    Hi all,
    I need to get the elapsed Time from the epoch in microsecond. I see is present a function qint64 QDateTime::currentMSecsSinceEpoch () that returns the time in millisecond. Is present a similar function that returns the time in microseconds?

    Thanks

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      qint64 QElapsedTimer::nsecsElapsed () const

      How precise the output is depends on the platform, though.

      PS: Not exactly what you asked for, but the closest thing I found.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        valeria70
        wrote on last edited by
        #3

        Ok Thanks,

        I have already seen this function but returns the number of nanoseconds from the start of QTimer.
        I need the number of microsecond form the epoch that in the function QDateTime::currentMSecsSinceEpoch () is 1/01/1970 ( in my case could be set to another date)..

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

          If it's not really important what the start time is (as long as it's some fixed point in time), you could start a QElapsedTimer at application start, and measure the nsecs from there. But I do not know your use case, so I can't really advise.

          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