[Interest] Proper use of SharedPointer/WeakPointer

Jason H scorp1us at yahoo.com
Thu Feb 23 15:10:51 CET 2012


I have an object database (objects inherit QObject) which is queryable. The result of the query is a list of zero or more objects. I don't want to give pointers themselves, as people could call delete on them and destroy the database.

In this example:

QList<QObject*> results = objDb.query();

I want results to be weak pointers. such that delete results.at(0) will not actually delete an object, just the pointer in the list. 
When creating my object database, do I store real pointers or QSharedPointers?
In the list am I returning QSharedPointers or QWeakPointers?

Is there a better pointer class that I should be using?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120223/15008891/attachment.html>


More information about the Interest mailing list