[Interest] QHash memory management
preeteesh kakkar
preeteesh.kakkar at gmail.com
Tue Aug 5 23:24:28 CEST 2014
Yes, you do need to delete them. You can keep them as scoped_ptr instead of
raw pointer.
On Aug 5, 2014 5:10 PM, "Jason R. Kretzer" <jason at gocodigo.com> wrote:
> Just a quick question about using QHash with pointers.
>
> Lets say I have the following snippet:
>
> //===========
>
> QWebView *view;
> QHash<int, QWebView *> hash;
>
> for(int i=0; i<10; i++) {
> view = new QWebView(this);
> hash.insert(i, view);
> }
>
> ////go do something meaningful
>
> //or do a hash.clear();
> for(int j=0; j<10; j++) {
> hash.remove(j);
> }
>
> //===========
>
>
> After the remove or clear is called, do I still need to delete the
> pointers? If so, would I just iterate through them using the value
> function and delete them one by one?
>
> -Jason
>
> --
> //-----------------------//
> Jason R. Kretzer
> Lead Application Developer
> jason at gocodigo.com
> C:606.792.0079
> H:606.297.2551
> //-----------------------//
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140805/728e8fed/attachment.html>
More information about the Interest
mailing list