首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >QCustomPlot加法QCustomItemText

QCustomPlot加法QCustomItemText
EN

Stack Overflow用户
提问于 2017-03-08 17:47:56
回答 1查看 806关注 0票数 1

我正在尝试将文本项添加到QCustomPlot小部件中。QCPItemText构造函数将指向QCustomPlot小部件的指针作为参数。

QCPItemText::QCPItemText ( QCustomPlot * parentPlot)

在创建QCPItemText对象之后,它可以使用成员函数QCustomPlot::addItem()添加到小部件中。但我的问题是程序没有编译。它说没有名为QCustomPlot::addItem()的成员函数。但是这个示例似乎就是这么做的。我很困惑。

这是我代码的一部分;

代码语言:javascript
复制
    //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);

EN

回答 1

Stack Overflow用户

发布于 2018-01-26 07:52:40

changelog.txt文件的第79行中,它存在于QcustomPlot安装路径中,您将看到它读到:

删除了QCustomPlot::addItem,不再需要了,因为条目现在会自动注册到它们的构造函数中。

所以你不需要currentWidget->addIem(itemText)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42678373

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档