class InfoVisitor : public osg::NodeVisitor { public: InfoVisitor():osg::NodeVisitor(TRAVERSE_ALL_CHILDREN) { count = 0; } virtual void apply(osg::Node& node) { std::string str=node.className(); if (count == 0) { QTreeWidgetItem* item=new QTreeWidgetItem; item->setText(0,QString(str.data())); map[count].push_back(item); rootList.append(item); } else { QVector<QTreeWidgetItem *> parent=map[count-1]; QTreeWidgetItem* item=new QTreeWidgetItem(parent[parent.size()-1],QStringList(QString(str.data()))); parent[parent.size()-1]->addChild(item); map[count].push_back(item); } count ++; traverse(node); count --; } /*virtual void apply(osg::Geometry& geometry) { traverse(geometry); }*/ public: int count; QList<QTreeWidgetItem *> rootList; QMap<int,QVector<QTreeWidgetItem *>> map; };