I am currently plotting a digital signal in Qt with QCustomPlot but it seems that when the number of samples is greater than 10000000 the operation becomes very slow. I have a time vector and a data vector and I'm setting the data like this:
QCustomPlot *plot;
QCPGraph *graph;
graph->setData(time, data);
Any chance to make this more efficient?
解决方案
Because QCustomPlot uses internally a QCPDataMap (which is a typedef of QMap) this means that it is using a map to store the actual data sorted by x coordinates (keys). Unfortunately the QCPGraph::setData(const QVector &x, const QVector &y) method doesn't take advantage of the fact that samples could be ordered and doesn't use the insertion hint, so this improved results significantly:
QCPDataMap *data = new QCPDataMap();
size_t len = x.size();
auto xp