我在这个例子中实现了一个自定义标注类 Callout Example
QPolarChart *chart = new QPolarChart();
Callout *callout = new Callout(chart);
如果我只能访问图表(标注超出范围),我如何才能重新获得对标注的访问权限。我考虑过使用
QObjectList children = chart->children();
但标注不在这里。 我怎样才能再次访问标注?
最佳答案
您必须使用 childItems()
,这会返回 QGraphicsItem
的子项。
for(QGraphicsItem *childItem: chart->childItems()){
if(Callout *c = dynamic_cast<Callout *>(childItem)){
//use c
}
}
关于c++ - qt 从 QChart 获取子项(标注),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51420994/