Reputation: 11619
I can't clear the items in a QCustomPlot
. The method QCustomPlot::itemCount()
always returns 0.
QCustomPlot *plot = new QCustomPlot(this);
qDebug() << plot->itemCount(); // returns 0
QCPItemText *textLabel = new QCPItemText(plot);
qDebug() << plot->itemCount(); // returns 0
Maybe QCPItemText
is not considered as an item, but how do I clear QCPItemText
then? Or reset QCustomPlot
?
Upvotes: 0
Views: 1337
Reputation: 1711
Use this after you allocate textLabel :
plot->addItem(textLabel);
From the documentation :
bool QCustomPlot::addItem ( QCPAbstractItem * item)
Adds the specified item to the plot. QCustomPlot takes ownership of the item.
Returns true on success, i.e. when item wasn't already in the plot and the parent plot of item is this QCustomPlot.
Upvotes: 1