Sky of Izalith
Sky of Izalith

Reputation: 11

Qt5 QCustomPlot. Large graph in real time

I am currently working on an application that plots data from ADC in real time. In some cases I have to plot about 150k points and it takes some time. So the problem is the data may arrive with higher frequency than I am able to plot it.

I don't need high framerate. Also I can effort skipping some data.

I am using: OS Windows 7, Qt 5.5, QCustomPlot.

So question is: How exactly do I prevent re-plotting until previous re-plot is finished to keep the application responsive?

Thanks.

Upvotes: 1

Views: 1630

Answers (1)

Nejat
Nejat

Reputation: 32635

You can have a slot which only receives new arrived data and stores them in a data structure like a QVector and periodically update plot with the received data in certain intervals using a QTimer.

So the slot for receiving data is like :

void receiveData(QVector<double> data)
{
     receivedData.append(data);
}

And the slot which is connected to timeOut signal of a timer with certain interval is like :

void receiveData()
{
     plot->graph()->setData(keyVector, receivedData);
     plot->replot();
}

This way the plot is only updated in certain intervals independent of the rate of input data.

Upvotes: 1

Related Questions