ShaChris23
12th November 2009, 01:53
I'm storing "new" objects into a QList, and was wondering which Qt smart pointer should be used for it. Obviously, the memory leak way is to just store the plain-old pointer into the QList (and have my program leaks memory).
I think the functional requirement I want is that when the QList destructs, I want all of the smart pointers in the list to delete the object it's holding.
Which smart pointer would do this for me? I want the one that incurs the least amount of overhead.
I'm using 4.6, so I have access to all of the Qt smart pointers.
Similar question was posted here (http://stackoverflow.com/questions/789532/qlist-and-sharedptr), but the guy uses Boost's smart pointer.
I think the functional requirement I want is that when the QList destructs, I want all of the smart pointers in the list to delete the object it's holding.
Which smart pointer would do this for me? I want the one that incurs the least amount of overhead.
I'm using 4.6, so I have access to all of the Qt smart pointers.
Similar question was posted here (http://stackoverflow.com/questions/789532/qlist-and-sharedptr), but the guy uses Boost's smart pointer.