The Qt structure has a signal for all QObject that are placed before the destruction of this QObject . This event can be used to make the QObject* variable automatically empty when the object it points to is destroyed.
But for this you need to use relatively much code. You will need to register a signal and associate it with a variable. Not very convenient in my opinion.
Can I configure (in Qt) that a pointer to a QObject automatically cleared when a QObject destroyed?
source share