I have a graph that needs to be updated in real time, for this I have a class that inhertis from QwtSeriesData<QPointF> and implements the methods sample and size, this series is attached to a QwtPlotCurve. Now the thing is that when adding a ton of points (not that many around 10K) the replotting gets super slow. I have pinpointed this to qwt trying to plot ALL the points in my series data irrespectively of my axis range. So I added a stride check on the sample method

Qt Code:
  1. QPointF linear_data::sample(size_t i) const {
  2. if (i * stride < data.size()) {
  3. QPointF res(i, data[i * stride]);
  4. return res;
  5. }
  6. }
To copy to clipboard, switch view to plain text mode 

where stride is the maximum number of points im allowing in my QwtSeries (around 25K) divided by the widget size in pixels (this size is the same as the xBottom scale).

Is there a way to avoid doing this from my class that inherits from QwtSeriesData and force the QwtPlot to apply this stride instead? seems my 'fix' is not very general.

In short: My axis range is 0 to N, my point range is 0 to M, is there a way to tie these ranges so it doesn't graph all M points and instead graph N points?