[Interest] QWeakPointer in Qt5

Thiago Macieira thiago.macieira at intel.com
Wed Jun 20 08:27:57 CEST 2012


On quarta-feira, 20 de junho de 2012 06.42.52, Philippe wrote:
> In Qt 5 in git, I have seen changes to this implementation. Mainly, in
> Qt 4.8, it was stated that "QWeakPointer serves as a replacement to
> QPointer". This is no longer the case and this is mentionned as
> deprecated (qsharedpointer.cpp).
> 
> QWeakPointer was quoted in 4.8 as "more efficient than QPointer, so it
> should be preferred in all new code.".
> 
> I use it a lot without trouble. So I would like to know why this (apparent)
> regression?
> 
> Question for Thiago I guess...

Yes, I need to blog about this (I have a draft actually).

In Qt5, QPointer and QWeakPointer are equally efficient. However, we've split 
the usages:

 - QPointer when you want to use to track QObjects, just like original Qt 4.0
 - QWeakPointer when you want to track a QSharedPointer

The QWeakPointer constructor that takes a QObject is deprecated.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120620/f019dc4b/attachment.sig>


More information about the Interest mailing list