[Qt-interest] What is the use of QWeakPointer

Matthias Pospiech matthias.pospiech at gmx.de
Fri Apr 9 12:35:02 CEST 2010


Dan Milburn schrieb:
> The way I use it is as follows:
>
> QWeakPointer<MyObject> weakPointer = ...
> MyObject *o = weakPointer.data();
> if( o )
> {
>     // Do something with o
> }
>   
Here you are converting a weak pointer to a normal pointer and use the 
normal pointer in the following.
I could implement the same without the weak pointer. So where is the 
actual benefit?

Matthias






More information about the Qt-interest-old mailing list