C++ (Qt)QObject::~QObject() { ... if (d->parent) // remove it from parent object d->setParent_helper(0);}