Hi,
here's a suggestion:
void Molecule::deleteSelected()
{
if( isSelected ){
deleteLater();
return;
}
foreach( Bond *bond, findChildren<Bond*>() )
bond->deleteSelected();
}
void Molecule::deleteSelected()
{
if( isSelected ){
deleteLater();
return;
}
foreach( Bond *bond, findChildren<Bond*>() )
bond->deleteSelected();
}
To copy to clipboard, switch view to plain text mode
In this case you are not iterating and deleting the children list(dangerous!), but you are implicitely working on a copy.
Also you can remove the setName() calls, since you are only using the class names. You can get to them by calling QMetaObject::className()
Bookmarks