AFAIK there is not a direct support for QAbstractItemModel
in QCustomPlot
. I am not sure how you expect QCustomPlot
to draw contents of a QAbstractItemModel
. As you know the model could be a simple model or a complex one or even hierarchical. That's two much for a simple 2D plot like QCustomPlot
. But there seems to be a way to assign data of a subclass of QAbstractItemModel
to QCustomPlot
and that's using QCPDataMap.
You should populate the data of your model in QCPDataMap
and assign it to plot. That's something like :
QCPDataMap *data = new QCPDataMap();
for(int i=0; i<count; i++)
data->insertMulti(data->constEnd(), x[i], QCPData(x[i], y[i]));
plot->graph()->setData(data);
You can generate QCPDataMap
in your model using x and y values and assign it's pointer to plot.