Hi,
I'm trying to create some a telemetry visualization tool using Qt ant QCP.
In the UI, the user can select which laps to plot.
Data is stored in QVectors and each lap define the start and stop index in the data QVectors.
Whenever the user selects or deselects a lap, a slot is called to update the plot. I do the following:
1. Call clearGraphs and clearPlottables.
2. for loop on selected laps
2.1 Create the graph, add the data, replot.
If I use QCPGraphs everything works fine. The relevant section of code (the body of the for loop) is:
QCPGraph *graph = ui->myPlot->addGraph(); graph->setData(runData->vvdValues.at(0).mid(data_start, data_length), runData->vvdValues.at(4).mid(data_start, data_length));
The above works as expected. But I realized I need to use QCPCurve instead of QCPGraph (my data can have loops), so I tried to replace the above with:
QCPCurve *curve = new QCPCurve(ui->myPlot->xAxis, ui->myPlot->yAxis); ui->myPlot->addPlottable(curve); curve->setData(runData->vvdValues.at(0).mid(data_start, data_length), runData->vvdValues.at(4).mid(data_start, data_length));
But this crashes. Typically the first time the for loop is executed it works OK (one curve is plotted), but the second time (when 2 curves should appear) it crashes. It's not always like that, I'm under the impression it depends on the size of the data between different laps. Unless I'm doing something very wrong, there may be a problem in clearing some data structures.
MaX.