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. How can I get a difference between two DateTime intervals in micro and nano seconds?
Forum Updated to NodeBB v4.3 + New Features

How can I get a difference between two DateTime intervals in micro and nano seconds?

Scheduled Pinned Locked Moved Unsolved General and Desktop
22 Posts 6 Posters 9.9k Views 2 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.
  • J.HilkJ Offline
    J.HilkJ Offline
    J.Hilk
    Moderators
    wrote on last edited by
    #10

    You can use

    #include <QElapsedTimer>
    

    its has the function

    qint64 QElapsedTimer::nsecsElapsed() const
    

    that is nano seconds since last started.
    Available since Qt 4.7.


    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


    Q: What's that?
    A: It's blue light.
    Q: What does it do?
    A: It turns blue.

    1 Reply Last reply
    1
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #11

      That's what I would have proposed except his environment uses Qt 4.3.2

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      J.HilkJ 1 Reply Last reply
      1
      • SGaistS SGaist

        That's what I would have proposed except his environment uses Qt 4.3.2

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by J.Hilk
        #12

        @SGaist
        Oh, I missed that, sorry.
        For some reason all I thought was "pre Qt5.0 so it fits" .


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        mrjjM 1 Reply Last reply
        1
        • J.HilkJ J.Hilk

          @SGaist
          Oh, I missed that, sorry.
          For some reason all I thought was "pre Qt5.0 so it fits" .

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #13

          Hi
          He is trying the boost chrono as @VRonin suggest but
          im not sure building it with VS 2005 is great joy. ? :)

          VRoninV 1 Reply Last reply
          0
          • mrjjM mrjj

            Hi
            He is trying the boost chrono as @VRonin suggest but
            im not sure building it with VS 2005 is great joy. ? :)

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by VRonin
            #14

            @mrjj The current release uses C++11 but boost version 1.47.0 does not. I also think boost::chrono and std::chrono are the same thing

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            mrjjM 1 Reply Last reply
            1
            • VRoninV VRonin

              @mrjj The current release uses C++11 but boost version 1.47.0 does not. I also think boost::chrono and std::chrono are the same thing

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #15

              @VRonin
              Ah and such old version might have makefile for Vs 2005 included.
              We cross fingers :=)

              1 Reply Last reply
              1
              • srikanthS Offline
                srikanthS Offline
                srikanth
                wrote on last edited by
                #16

                can i use chrono in VS 2005 , am unable to get nanoseconds is there anyway to get nanoseconds in vs 2005 & Qt 4.3.2

                jsulmJ 1 Reply Last reply
                0
                • srikanthS srikanth

                  can i use chrono in VS 2005 , am unable to get nanoseconds is there anyway to get nanoseconds in vs 2005 & Qt 4.3.2

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #17

                  @srikanth As @VRonin said you can use Boost 1.47.0 (boost::chrono: https://theboostcpplibraries.com/boost.chrono).

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  srikanthS 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @srikanth As @VRonin said you can use Boost 1.47.0 (boost::chrono: https://theboostcpplibraries.com/boost.chrono).

                    srikanthS Offline
                    srikanthS Offline
                    srikanth
                    wrote on last edited by srikanth
                    #18

                    @jsulm i downloaded the boost.zip file from this link
                    [http://www.boost.org/users/history/version_1_63_0.html]

                    unzip them and then add something like INCLUDEPATH += C:/boost/boost_1_63_0/ to my pro file , if i run this code then it is getting error like this "fatal error LNK1104: cannot open file 'libboost_chrono-vc80-mt-gd-1_63.lib' " so what can i do now ? to get this lib file .

                    mrjjM jsulmJ 2 Replies Last reply
                    0
                    • srikanthS srikanth

                      @jsulm i downloaded the boost.zip file from this link
                      [http://www.boost.org/users/history/version_1_63_0.html]

                      unzip them and then add something like INCLUDEPATH += C:/boost/boost_1_63_0/ to my pro file , if i run this code then it is getting error like this "fatal error LNK1104: cannot open file 'libboost_chrono-vc80-mt-gd-1_63.lib' " so what can i do now ? to get this lib file .

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #19

                      @srikanth
                      Try the 1.47.0 one.
                      1_63 might be too new for VS 2005.

                      1 Reply Last reply
                      2
                      • srikanthS srikanth

                        @jsulm i downloaded the boost.zip file from this link
                        [http://www.boost.org/users/history/version_1_63_0.html]

                        unzip them and then add something like INCLUDEPATH += C:/boost/boost_1_63_0/ to my pro file , if i run this code then it is getting error like this "fatal error LNK1104: cannot open file 'libboost_chrono-vc80-mt-gd-1_63.lib' " so what can i do now ? to get this lib file .

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #20

                        @srikanth You need to link to the library mentioned in the error message:

                        LIBS += -LPATH_TO_BOOST_LIBS -lboost_chrono-vc80-mt-gd-1_63
                        

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        2
                        • srikanthS Offline
                          srikanthS Offline
                          srikanth
                          wrote on last edited by
                          #21

                          QueryPerformanceCounter is giving microseconds
                          but not in exactly
                          i have one doubt in this
                          please check my code once
                          https://paste.ofcode.org/gg6d6ESDmJHDkxxQmkUkbN

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #22

                            It depends on the source. You have all the explanations here.

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            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