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. QChart::scroll function messing with timer
QtWS25 Last Chance

QChart::scroll function messing with timer

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

    Hi, I'm new at QT and I'm making my first Qt Widget Application.

    It receives data through serial port and uses a QSplineSeries chart that updates and dislocates the x axis each 1 second (counted through a QTimer) using the QChart::scroll(dx, dy) function. I'm showing in the chart how many packets I received in 1 second. It's similar to the dynamic spline example.

    The problem that (I think) I have is because scroll() takes too much processing time and messes with my timer. I'm suppose to have 10 packets/s (1 each 100ms), but it becomes completely random when scroll() is activated. I also save the data that I'm receiving in a file, so it's easy to check what happened. At the end of each second I add an "endl", so the same thing that shows in the chart shows in my file. When I don't scroll the chart, the file has every second saved right. I also tested only updating the chart and not saving in the file, but it still doesn't work.

    Is there any known solution for this kind of problem? Do you have any suggestions to a scrolling function that doesn't mess with my timer or another kind of chart that would show a few recent inputs and keep updating?

    Thanks!

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

      Hi,

      Since you have several operations that are taking time, You should consider modifying your design. For example the file writing could be moved in it's own thread following the producer/consumer model so it won't block the gui.

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

      I 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Since you have several operations that are taking time, You should consider modifying your design. For example the file writing could be moved in it's own thread following the producer/consumer model so it won't block the gui.

        I Offline
        I Offline
        iagreen
        wrote on last edited by iagreen
        #3

        @SGaist sounds like a good idea. I'll do some changes and see if it gets better. Thanks!

        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