I am trying add a text item onto a QCustomPlot
widget. The QCPItemText
constructor takes a pointer to QCustomPlot
widget as an argument.
QCPItemText::QCPItemText ( QCustomPlot * parentPlot)
After creating the QCPItemText
object, it can added to the widget by using the member function, QCustomPlot::addItem()
. But my problem is the program doesn't compile. It says there no member function called QCustomPlot::addItem()
. But this example seems do this. I am confused.
This is part of my code;
//hash out current widget
QCustomPlot *currentWidget = GraphWindow::dynamicWidgetHash.value(slot);
//Setup font
QFont plotFont;
plotFont.setStyleHint(QFont::Helvetica);
plotFont.setBold(true);
plotFont.setWeight(8);
plotFont.setPointSize(16);
GraphWindow::setupBackground(slot);
QCPItemText itemText(currentWidget);
QString dataText = "No " + xLabel + " data found. \nPossibly the firm may not possess " + xLabel;
itemText.setText(dataText);
itemText.setPositionAlignment(Qt::AlignTop|Qt::AlignCenter);
itemText.position->setType(QCPItemPosition::ptAxisRectRatio);
itemText.position->setCoords(2,2);
itemText.setFont(plotFont);
itemText.setPen(QPen(Qt::white));
Where dynamicWidgetHash
is a QHash
object, which stores a QCustomPlot *
for each given key
.
The error occurs when I try to use this line
currentWidget->addIem(itemText);