Can Qt arrange for nullptr for QObject * when killing a QObject?

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?

+6
source share
1 answer

Not with a raw pointer, but Qt provides a template QPointer class that does exactly what you are describing.

+8
source

All Articles