Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QChart::scroll function messing with timer
iagreen last edited by
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?
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.
iagreen last edited by iagreen
@SGaist sounds like a good idea. I'll do some changes and see if it gets better. Thanks!