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 to measure an interval between messages.

How to measure an interval between messages.

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 4 Posters 314 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.
  • J Offline
    J Offline
    jenya7
    wrote on last edited by jenya7
    #1

    On a message receive I'd like to measure an interval in milliseconds to a previous message.
    So

     QTime cur_time = QTime::currentTime();
     cur_time.msecsTo(?);
    

    What should I place as an argument at msecsTo? a previous time stamp?

    JKSHJ 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You can use QElapsedTimer

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      J 1 Reply Last reply
      4
      • Christian EhrlicherC Christian Ehrlicher

        You can use QElapsedTimer

        J Offline
        J Offline
        jenya7
        wrote on last edited by jenya7
        #3

        @Christian-Ehrlicher said in How to measure an interval between messages.:

        You can use QElapsedTimer

         QElapsedTimer timer;
            timer.start();
        

        When do I start it? On an application start? Should It be global to all files that uses it?

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @jenya7 said in How to measure an interval between messages.:

          When do I start it? On an application start? Should It be global to all files that uses it?

          You start it when you want to start measuring your time - don't understand your question.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          J 1 Reply Last reply
          1
          • Christian EhrlicherC Christian Ehrlicher

            @jenya7 said in How to measure an interval between messages.:

            When do I start it? On an application start? Should It be global to all files that uses it?

            You start it when you want to start measuring your time - don't understand your question.

            J Offline
            J Offline
            jenya7
            wrote on last edited by
            #5

            @Christian-Ehrlicher said in How to measure an interval between messages.:

            @jenya7 said in How to measure an interval between messages.:

            When do I start it? On an application start? Should It be global to all files that uses it?

            You start it when you want to start measuring your time - don't understand your question.

            It has to be a global time reference cause messages comes asynchronously and I have to take an interval between two the-same-kind messages.

            Christian EhrlicherC 1 Reply Last reply
            0
            • J jenya7

              @Christian-Ehrlicher said in How to measure an interval between messages.:

              @jenya7 said in How to measure an interval between messages.:

              When do I start it? On an application start? Should It be global to all files that uses it?

              You start it when you want to start measuring your time - don't understand your question.

              It has to be a global time reference cause messages comes asynchronously and I have to take an interval between two the-same-kind messages.

              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @jenya7 said in How to measure an interval between messages.:

              I have to take an interval between two the-same-kind messages.

              Then create a QElapsedTimer per same message.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              J 1 Reply Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher

                @jenya7 said in How to measure an interval between messages.:

                I have to take an interval between two the-same-kind messages.

                Then create a QElapsedTimer per same message.

                J Offline
                J Offline
                jenya7
                wrote on last edited by jenya7
                #7

                @Christian-Ehrlicher said in How to measure an interval between messages.:

                @jenya7 said in How to measure an interval between messages.:

                I have to take an interval between two the-same-kind messages.

                Then create a QElapsedTimer per same message.

                a local one? don't understand from examples - timer.start(); - it takes the current system time?

                1 Reply Last reply
                0
                • J jenya7

                  On a message receive I'd like to measure an interval in milliseconds to a previous message.
                  So

                   QTime cur_time = QTime::currentTime();
                   cur_time.msecsTo(?);
                  

                  What should I place as an argument at msecsTo? a previous time stamp?

                  JKSHJ Offline
                  JKSHJ Offline
                  JKSH
                  Moderators
                  wrote on last edited by
                  #8

                  @jenya7 said in How to measure an interval between messages.:

                  What should I place as an argument at msecsTo? a previous time stamp?

                  Since you want to measure the interval between 2 messages, then the argument to msecsTo() should be the timestamp of the previous message.

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  J 1 Reply Last reply
                  0
                  • JKSHJ JKSH

                    @jenya7 said in How to measure an interval between messages.:

                    What should I place as an argument at msecsTo? a previous time stamp?

                    Since you want to measure the interval between 2 messages, then the argument to msecsTo() should be the timestamp of the previous message.

                    J Offline
                    J Offline
                    jenya7
                    wrote on last edited by jenya7
                    #9

                    @JKSH said in How to measure an interval between messages.:

                    @jenya7 said in How to measure an interval between messages.:

                    What should I place as an argument at msecsTo? a previous time stamp?

                    Since you want to measure the interval between 2 messages, then the argument to msecsTo() should be the timestamp of the previous message.

                    Thank you.
                    msecsTo() - is it absolute? I mean
                    previous timestamp = 23:50:00 (hh:ss:mm)
                    current timestamp = 00:10:00 (hh:ss:mm)
                    msecsTo() handles the case?

                    JonBJ 1 Reply Last reply
                    0
                    • J jenya7

                      @JKSH said in How to measure an interval between messages.:

                      @jenya7 said in How to measure an interval between messages.:

                      What should I place as an argument at msecsTo? a previous time stamp?

                      Since you want to measure the interval between 2 messages, then the argument to msecsTo() should be the timestamp of the previous message.

                      Thank you.
                      msecsTo() - is it absolute? I mean
                      previous timestamp = 23:50:00 (hh:ss:mm)
                      current timestamp = 00:10:00 (hh:ss:mm)
                      msecsTo() handles the case?

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #10

                      @jenya7
                      You should test what you ask. It's 3 lines of code, and when you've written it you'll know how to use it.

                      1 Reply Last reply
                      2

                      • Login

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