c++ - How can I delete all nodes recursively in the root entity of Qt3DWindow? -
i want delete root nodes of root scene of qt3dwindow. contains multiple hierarchy levels of nodes. want remove references , delete objects. simplest way that?
i used recursive function it:
void deletechildrenrecursively(qt3dcore::qnodevector& vector) { foreach(qt3dcore::qnode* node, vector){ qt3dcore::qentity* entity = (qt3dcore::qentity*)node; qlist<qt3dcore::qcomponent*> componentstodelete; foreach(qt3dcore::qcomponent* component, entity->components()){ entity->removecomponent(component); delete(component); component = null; } deletechildrenrecursively(node->childnodes()); delete(node); node = null; } }
it deletes qentity , qcomponent objects recursively.
usage:
qt3dcore::qentity* rootentity = new qt3dcore::qentity(); view->setrootentity(rootentity) ... deletechildrenrecursively(rootentity->childnodes());
Comments
Post a Comment