QCustomPlot Discussion and Comments

no addPlottable method for class QCustomPlotReturn to overview

I could not find the method addPlottable for class QCustomPlot and I am wondering how do i add a QCPCurve/QCPFinancial to QCustomPlot?

Thanks.
Aimin

The methods addPlottable and addItem are removed in QCustomPlot 2.0 and not needed anymore. See the changelog.

Just create your plottable as usual and leave out the addPlottable call.

I'm trying to add and interact with several plots (lines and bars).
I can show the plots, however, I can't access the QCPBar using customPlot->graph(N) because it's not there (seems not added with the contruction).

┬┐How can I access to QCPBars plots from my customplot?

Here is part of my code:

 
QCPBars *plot2Dbars = new QCPBars(customPlot->xAxis, customPlot->yAxis);
plot2Dbars->setAntialiased(false);
plot2Dbars->setWidthType(QCPBars::wtPlotCoords);
plot2Dbars->setWidth(barSize);
plot2Dbars->setName(titleData);
plot2Dbars->setPen(pen);
plot2Dbars->setBrush(QBrush(pen.color()));
plot2Dbars->setData(xData,yData);

//....
//I know the N graph was a QCPBar, and I want to edit something of it:
int barGraphIndex = N;
QCPGraph *barGraph = customPlot->graph(barGraphIndex);

Result:

QCPGraph* QCustomPlot::graph(int) const index out of bounds:

QCPBars isnt a graph. you would need to call customPlot->plottable() instead. also, as i pointed out in a different thread, you really shouldnt rely on the index in qcustomplot, you should keep track of the pointers yourself.

ok, thank you