I need a pointer container that takes ownership of the pointers - i.e. when an element is removed, or the container goes out of scope, it frees all its pointers, like in boost::ptr_vector
.
QList<QScopedPointer<AbstractClass> >
doesn't work (compile errors, no copy constructor?).
Right now I'm using QList<QSharedPointer<AbstractClass> >
, but it feels like an overkill, with its reference counting and the expensive mutex for multithreading.
Edit: I just learned about QPtrList (thanks @ForEveR) which was that very equivalent in Qt3, but was removed from later versions. I just don't understand why they would remove it.