[英]QCustomPlot adding QCustomItemText
我正在尝试将文本项添加到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);
在QcustomPlot
安装路径中存在的changelog.txt
文件的第 79 行,您将看到它显示为:
删除了
QCustomPlot::addItem
,不再需要,因为项目现在会在其构造函数中自动注册。
所以你不需要currentWidget->addIem(itemText)
;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.