qt get child (Callout) from QChart



我实现了一个自定义Callout类,类似于本例中的Callout example

QPolarChart *chart = new QPolarChart();
Callout *callout = new Callout(chart);

如果我只能访问图表(标注超出范围(,如何重新获得对标注的访问权限。我考虑过使用

QObjectList children = chart->children();

但callout不在这里。如何再次访问callout?

您必须使用childItems(),这将返回QGraphicsItem的子级。

for(QGraphicsItem *childItem: chart->childItems()){
if(Callout *c = dynamic_cast<Callout *>(childItem)){
//use c
}
}

最新更新