Q自定义-隐藏/显示所选图形

QCustomplot - Hide / Show selected graph

本文关键字:图形 显示 自定义 隐藏      更新时间:2023-10-16

我想通过直接在绘图上选择来隐藏/显示图形。我的想法是这样的:

myPlot->graph(graphIdx)->setVisible(false);

其中CCD_ 1是CCD_。

我的问题是:有没有办法得到所选图的索引graphIdx?这可能很琐碎,但老实说,我想不通。

提前感谢

A。

使用返回QList<QCPGraph *>的函数QCustomPlot::selectedGraphs(在您的情况下,它应该只有1个元素)。您可以在这些指针上直接调用setVisible。您可能需要QCustomPlot::selectedPlottables,如文档所示。

我认为您可以从QCustomPlot::selectedGraphs()中获取指针。

auto ololo = new QCustomPlot();
...
foreach(QCPGraph* gr, ololo->selectedGraphs()){
    gr->setVisible(false);
}