I have a situation where the QSharedPointer managed entity signals that it has completed its assignment and is soon ready to be deleted (after execution left the function emitting my readyForDeletion signal). When working with regular pointers, I simply call QObject::deleteLater on the object, however this is not possible with the QSharedPointer -managed instance. My workaround is this:
template<typename T> class QSharedPointerContainer : public QObject { QSharedPointer<T> m_pSharedObj; public: QSharedPointerContainer(QSharedPointer<T> pSharedObj) : m_pSharedObj(pSharedObj) {}
This works well, however when using this method there is a lot of overhead (allocating a new QObject , etc.). Is there a better solution to handle such situations?
source share