Do we required to call qDeleteAll if the QList is of QSharedPointer?



  • Hi There,

    We have qList having raw pointers, we are replacing our raw pointers with QSharedPointer.
    If we have QList<QSharedPointer<Foo>>, then do we required to call qDeleteAll on that QList?
    or it will be automatically taken care by Qt? As we are getting error if we try to call qDeleteAll on list of QSharedPointer.

    Please suggest.

    Thanks,
    Hetal


  • Moderators

    @Hetal
    no you don't need to call qDeleteAll in that case, since the QSharedPointer takes care of it. If the QList is also created on the stack you don't need to delete it too.

    The question is, do you need the (little) overhead of QSharedPointer at all?!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.