Search code examples
qtqtguiqcustomplot

QCustomPlot misplots during plot resize


I have a QCustomPlot which is graphing incoming data. The plots look great but when I resize the window or zoom or drag abruptly the data get misplotted, as if I dragged a canvas out from under a painter.

Why does this happen? I will be trying to add a condition in my plotting slot to detect if a drag is occurring and hold off the plotting but I wish I didn't have to.

If QCustomPlot has the keys and values, why can't it position them correctly during a replot no matter how the plot has been resized?


Solution

  • This ended up not being a QCustomPlot issue really, which is why it wasn't obvious at first. In my program I am receiving real time data. The data gets timestamped in my add data/replot function. Since replots are queued, when I dragged and resized the plots, it caused a delay in when my add data/replot function got called thus throwing off the time stamp.

    I fixed this by creating the timestamp as soon as I have parsed my data, which is managed by a different class. I then pass the timestamp to my add data/replot function.

    So if you are using real time data, take your time stamp as early in your program as possible, and don't put it in a function which is likely to get delayed or queued behind other threads.