[Development] QtCS - QObject discussion

André Somers andre at familiesomers.nl
Mon Jul 29 14:00:05 CEST 2013


Op 29-7-2013 13:17, Olivier Goffart schreef:
> 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?
Good point. I'm not sure if how many API's there are in Qt that take raw 
pointers to QObjects outside of constructors, but my feeling is that 
there are problably too many to justify a break in consistence here. 
Also, fixing other points will result in API bloat all over Qt. That is 
definiately not worth the benefit.
> 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/
That would solve it, but I am not convinced either way. I am also not 
convinced that not having to use .data() is worth the risk introducing 
operator T*. At the very least the delete should then be disabled as well.

André

-- 
You like Qt?
I am looking for collegues to join me at i-Optics!




More information about the Development mailing list