Would it be possible for an insertPlottable function to be added in the future? Like so:
bool insertPlottable(int index, QCPAbstractPlottable *plottable) { if(mPlottables.contains(plottable)) { qDebug() << Q_FUNC_INFO << "plottable already added to this QCustomPlot:" << reinterpret_cast<quintptr>(plottable); return false; } if(plottable->parentPlot() != this) { qDebug() << Q_FUNC_INFO << "plottable not created with this QCustomPlot as parent:" << reinterpret_cast<quintptr>(plottable); return false; } mPlottables.insert(index, plottable); if(mAutoAddPlottableToLegend) { plottable->addToLegend(); } if(qobject_cast<QCPGraph *>(plottable)) { mGraphs.insert(index, static_cast<QCPGraph *>(plottable)); } if(!plottable->layer()) { plottable->setLayer(currentLayer()); } return true; }
Also, I've noticed that the new layout system doesn't completely remove all the area used by invisible layout items. For example, if I add a title to a plot and then hide that title, the title still causes some area to be taken anyway from the axis rect. For Qt Widgets on the other hand, the layout system completely removes the spacing, margins, etc. required for the hidden item.