[Development] QtCS - QObject discussion

Olivier Goffart olivier at woboq.com
Mon Jul 29 13:17:22 CEST 2013


On Sunday 28 July 2013 20:00:00 Andre Somers wrote:
> Op 26-7-2013 23:48, Olivier Goffart schreef:
> > This is a summary of what's written there:
> > https://qt-project.org/groups/qt-contributors-summit-2013/wiki/QObject
> > 
> > - As it was decided in the QtCore discussion, new features may require
> > C++11
> > 
> > - We want to add an overload of QObject::connect that takes both a pointer
> > to a "receiver" and a simple functor (as opposed to a pointer to member
> > function) Use case is to have automatic disconnection of connections to
> > lambda functions, and also be able to use thread affinity and
> > QueuedConnection. Dario Freddi said he will have a look.
> 
> Would it be feasible to be able to connect directly to QObject or
> QObject subclasses that are stored in a shared pointer, scoped pointer
> or QPointer? It is just sugar of course, but it would be neat if I don't
> need the .data() anymore on these for connect statements...

For QPointer, it should already work because QPointer has a operator T*.
QSharedPointer and QScopedPointer do not have operator T*. Apparently, this is 
intentional.

I do not beleive we should add this convinience in QObject::connect. Or why 
not in every places that takes pointer?  Why would QObject::connect be any 
special in that respect?

I'd personnally rather add the operator T* convinience to the QScopedPointer 
and QSharedPointer.  I know the reasons it is not there, but i am not 
convinced they are worth the inconvenience:
http://herbsutter.com/2012/06/21/reader-qa-why-dont-modern-smart-pointers-implicitly-convert-to/

-- 
Olivier 

Woboq - Qt services and support - http://woboq.com - http://code.woboq.org



More information about the Development mailing list