What is the difference between QPointer, QSharedPointer and QWeakPointer classes in Qt?
QPointer: QPointer can only point to QObject instances. It will be automatically set to nullptr if the pointed to object is destroyed. It is a weak pointer specialized for QObject. Consider this fragment: QObject *obj = new QObject; QPointer<QObject> pObj(obj); delete obj; Q_ASSERT(pObj.isNull()); // pObj will be nullptr now QSharedPointer A reference-counted pointer. The actual … Read more