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. Why does setRange of QDateTimeAxis take so much time?
Forum Updated to NodeBB v4.3 + New Features

Why does setRange of QDateTimeAxis take so much time?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 715 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.
  • tovaxT Offline
    tovaxT Offline
    tovax
    wrote on last edited by
    #1

    I used QChart to display real-time curves, and found that setRange() of QDateTimeAxis take so much time, about 30ms.
    Here is a link to the demo code: RealTimeCurve

            QElapsedTimer t;
            t.start();
            beginTime = QDateTime::currentDateTime();
            endTime = beginTime.addMSecs(MaxSize * static_cast<uint32_t>(timer->interval()));
            axisX->setMin(beginTime);
            axisX->setMax(endTime); // TODO: waste about 30ms
            // axisX->setRange(beginTime, endTime);
            qDebug() << "QElapsedTimer" << t.elapsed();
    

    Could you help me, please?
    Best Regards!

    JonBJ 1 Reply Last reply
    0
    • tovaxT tovax

      @JonB
      Hi,
      Thanks very much for your reply.
      I want to achieve a display like this:real-time-curve-gif
      So I have to reset the range when the data is updated.

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

      @tovax
      You asked "Why does setRange of QDateTimeAxis take so much time?". I am suggesting it is because it already has a lot of points. I suggested you try without (many) points to see if this is the case. Did you try that? If that is not the reason you should discover that first.

      I recall a long time ago the same question/problem being asked in this forum. I'm afraid I don't recall what/whether there was a good resolution. There is a (possibly old?) source code at https://www.advsofteng.com/doc/cdcppdoc/realtimezoomscrollqt.htm which you might look at to see if it helps you any? There is QChart::scroll(). Maybe Google for "qchart real time`, something like https://stackoverflow.com/questions/50853387/qchart-realtime-performance or other hits may help you?

      tovaxT 2 Replies Last reply
      1
      • tovaxT tovax

        I used QChart to display real-time curves, and found that setRange() of QDateTimeAxis take so much time, about 30ms.
        Here is a link to the demo code: RealTimeCurve

                QElapsedTimer t;
                t.start();
                beginTime = QDateTime::currentDateTime();
                endTime = beginTime.addMSecs(MaxSize * static_cast<uint32_t>(timer->interval()));
                axisX->setMin(beginTime);
                axisX->setMax(endTime); // TODO: waste about 30ms
                // axisX->setRange(beginTime, endTime);
                qDebug() << "QElapsedTimer" << t.elapsed();
        

        Could you help me, please?
        Best Regards!

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

        @tovax
        I might be wrong(!), but doesn't changing the range require complete rescaling/redrawing of the entire chart? If you already have a lot of points plotted(?), that could be quite a bit of work? Is there anyway you can set the range before you plot the points (or at least test that)?

        tovaxT 1 Reply Last reply
        0
        • JonBJ JonB

          @tovax
          I might be wrong(!), but doesn't changing the range require complete rescaling/redrawing of the entire chart? If you already have a lot of points plotted(?), that could be quite a bit of work? Is there anyway you can set the range before you plot the points (or at least test that)?

          tovaxT Offline
          tovaxT Offline
          tovax
          wrote on last edited by tovax
          #3

          @JonB
          Hi,
          Thanks very much for your reply.
          I want to achieve a display like this:real-time-curve-gif
          So I have to reset the range when the data is updated.

          JonBJ 1 Reply Last reply
          0
          • tovaxT tovax

            @JonB
            Hi,
            Thanks very much for your reply.
            I want to achieve a display like this:real-time-curve-gif
            So I have to reset the range when the data is updated.

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

            @tovax
            You asked "Why does setRange of QDateTimeAxis take so much time?". I am suggesting it is because it already has a lot of points. I suggested you try without (many) points to see if this is the case. Did you try that? If that is not the reason you should discover that first.

            I recall a long time ago the same question/problem being asked in this forum. I'm afraid I don't recall what/whether there was a good resolution. There is a (possibly old?) source code at https://www.advsofteng.com/doc/cdcppdoc/realtimezoomscrollqt.htm which you might look at to see if it helps you any? There is QChart::scroll(). Maybe Google for "qchart real time`, something like https://stackoverflow.com/questions/50853387/qchart-realtime-performance or other hits may help you?

            tovaxT 2 Replies Last reply
            1
            • JonBJ JonB

              @tovax
              You asked "Why does setRange of QDateTimeAxis take so much time?". I am suggesting it is because it already has a lot of points. I suggested you try without (many) points to see if this is the case. Did you try that? If that is not the reason you should discover that first.

              I recall a long time ago the same question/problem being asked in this forum. I'm afraid I don't recall what/whether there was a good resolution. There is a (possibly old?) source code at https://www.advsofteng.com/doc/cdcppdoc/realtimezoomscrollqt.htm which you might look at to see if it helps you any? There is QChart::scroll(). Maybe Google for "qchart real time`, something like https://stackoverflow.com/questions/50853387/qchart-realtime-performance or other hits may help you?

              tovaxT Offline
              tovaxT Offline
              tovax
              wrote on last edited by
              #5

              @JonB
              This demo only has 10 points now.
              I will read these posts, thanks again.

              1 Reply Last reply
              0
              • tovaxT Offline
                tovaxT Offline
                tovax
                wrote on last edited by
                #6

                Test Results:
                1.
                "test code" in function initialize():
                Debug output: QElapsedTimer "1" 0 0
                Consume 0ms.
                2.
                "test code" in timer slot onTimer():
                Debug output: QElapsedTimer "2" 53 46
                Consume 53ms.

                test code as follows:

                void JCDemoRealTimeCurve::test(uint32_t num)
                {
                    QElapsedTimer t;
                    t.start();
                    beginTime = QDateTime::currentDateTime();
                    endTime = beginTime.addMSecs(MaxSize * static_cast<uint32_t>(timer->interval()));
                    axisX->setMin(beginTime);
                    axisX->setMax(endTime); // TODO: waste about 30ms
                    // axisX->setRange(beginTime, endTime);
                    qDebug() << "QElapsedTimer" << QString::number(num) << t.elapsed() << beginTime.msecsTo(QDateTime::currentDateTime());
                }
                
                1 Reply Last reply
                0
                • JonBJ JonB

                  @tovax
                  You asked "Why does setRange of QDateTimeAxis take so much time?". I am suggesting it is because it already has a lot of points. I suggested you try without (many) points to see if this is the case. Did you try that? If that is not the reason you should discover that first.

                  I recall a long time ago the same question/problem being asked in this forum. I'm afraid I don't recall what/whether there was a good resolution. There is a (possibly old?) source code at https://www.advsofteng.com/doc/cdcppdoc/realtimezoomscrollqt.htm which you might look at to see if it helps you any? There is QChart::scroll(). Maybe Google for "qchart real time`, something like https://stackoverflow.com/questions/50853387/qchart-realtime-performance or other hits may help you?

                  tovaxT Offline
                  tovaxT Offline
                  tovax
                  wrote on last edited by
                  #7

                  @JonB
                  Hi,
                  This is a very good website! Thank you very much!
                  https://www.advsofteng.com/
                  Best Regards!

                  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 Extensions
                  • Unsolved