我正在尝试将文本项添加到QCustomPlot小部件中。QCPItemText构造函数将指向QCustomPlot小部件的指针作为参数。
QCPItemText::QCPItemText ( QCustomPlot * parentPlot)
在创建QCPItemText对象之后,它可以使用成员函数QCustomPlot::addItem()添加到小部件中。但我的问题是程序没有编译。它说没有名为QCustomPlot::addItem()的成员函数。但是这个示例似乎就是这么做的。我很困惑。
这是我代码的一部分;
//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));其中dynamicWidgetHash是一个QHash对象,它为每个给定的key存储一个QCustomPlot *。
当我尝试使用这一行时会发生错误。
currentWidget->addIem(itemText);
发布于 2018-01-26 07:52:40
在changelog.txt文件的第79行中,它存在于QcustomPlot安装路径中,您将看到它读到:
删除了
QCustomPlot::addItem,不再需要了,因为条目现在会自动注册到它们的构造函数中。
所以你不需要currentWidget->addIem(itemText);
https://stackoverflow.com/questions/42678373
复制相似问题