QObject has a signal to inform anyone that it's getting destroyed : QObject::destroyed
Signal are calling slots synchronously.
Qt object tree is smart enough to know when a child or a parent has been destroyed and update the tree accordingly, same thing with smart pointers I believe (like Ahmed AEK answer is explaining with the order of destructors being called https://stackoverflow.com/a/79463172/6165833).