用qcpitemtracer在qcustomplot中显示点
Show points in QCustomPlot with QCPItemTracer
我正在尝试使用更长的时间来创建一种机制,该机制可以在与坐标的图上创建我的观点旁边的文本标签。从文档中,我读到我需要为此使用qcpitemtracer。无论我如何尝试,我都无法使用此对象在图上显示任何其他项目。在qcustomplot示例中,有一个程序用户用户qcpitemtracer,但是当我运行它时,我也看不到任何其他对象。我正在尝试从Bellow运行示例代码:
QCPItemTracer *phaseTracer = new QCPItemTracer(customPlot);
customPlot->addItem(phaseTracer);
phaseTracer->setGraph(customPlot->graph(DATA_PLOT));
phaseTracer->setGraphKey(7);
phaseTracer->setInterpolating(true);
phaseTracer->setStyle(QCPItemTracer::tsCircle);
phaseTracer->setPen(QPen(Qt::red));
phaseTracer->setBrush(Qt::red);
phaseTracer->setSize(7);
从我的理解来看,这应该在我的情节点上增加红色圆圈。它不是。在此问题上,我确实会提供任何帮助,也许是一些示例代码。我为此挣扎了很长时间。
我设法使标签正常工作:
returnCodes_t PlotData::insertPointLabel(const int& index, const double& x, const double& y)
{
QCPItemText *textLabel = new QCPItemText(m_parentPlot);
m_parentPlot->addItem(textLabel);
textLabel->setPositionAlignment(Qt::AlignBottom|Qt::AlignHCenter);
textLabel->position->setType(QCPItemPosition::ptPlotCoords);
textLabel->position->setCoords(x, y); // place position at center/top of axis rect
textLabel->setText(QString("x%1 y%2").arg(x).arg(y));
textLabel->setVisible(labelsVisible);
m_pointLabels.insert(index, textLabel);
return return_success;
}
相关文章:
- 比较并显示使用最小值(a,b)和最大值(a、b)升序排列的4个数字
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 字符串-C++后显示的随机字符
- 继承期间显示未知行为的子类
- 仅使用绝对值对数组进行排序,并在C++中显示实际值
- 程序崩溃并显示"std::out_of_range"错误
- 如何在C++中用std::cout正确显示带十六进制的字符串文本
- 为什么在C的循环中使用printf的Rust代码不显示输出,而在C++的循环中显示std::cout
- 从数据库实时显示QT c++中的数据
- 当使用比格式支持的精度更高的精度来显示数字时,会写出什么数据
- 显示错误输出的简单数组排序程序
- Qt自定义QPush按钮未显示在布局上
- C++射线示踪剂ppm表示没有足够的数据来显示图像
- 显示基于用户输入的整数的字符
- 使用QTreeView,如何通过调用函数只突出显示特定的行/列
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 示例外壳应用程序显示的 V8 "segmentation fault (core dumped)"错误
- 用qcpitemtracer在qcustomplot中显示点
- QCustomPlot-在customPlot下方的QCPAxisRect上显示项目
- QCustomPlot/Widget不显示图形/更新