[Interest] Are slots even needed these days?

Sze Howe Koh szehowe.koh at gmail.com
Thu Mar 17 00:40:15 CET 2016


On 17 March 2016 at 01:03, charleyb123 . <charleyb123 at gmail.com> wrote:
> On Wed, Mar 16, 2016 at 10:57 AM, Giuseppe D'Angelo
> <giuseppe.dangelo at kdab.com> wrote:
>>
>> Il 16/03/2016 17:24, charleyb123 . ha scritto:
>>>
>>> Current slot implementation bridges runtime-reflection capabilities
>>> (provided by QMetaObject), and provides the thread-safe event queue that
>>> bridges "slot-execution" to occur on the "target-thread" for which the
>>> "target-QObject" has "affinity".  Lambdas alone cannot do this -- some
>>> kid of "event-queue" would be required that is "thread-aware" (yes,
>>> could be provided through a library of some kind, that happens to be
>>> what Qt is doing).
>>
>>
>> This thread wasn't talking about lambdas, rather about the "old" connect
>> syntax (SIGNAL/SLOT based) vs the "new" one (PMF based).
>>
>> Anyhow, since you brought lambdas into discussion, you can pass an
>> affinity object for them as well:
>>
>>> https://doc.qt.io/qt-5/qobject.html#connect-5
>>
>>
>
> Ah, thanks:  I misunderstood the thread topic (sorry).  ;-)
>
> Agree that I don't have a use case for the "old" connect syntax anymore
> (fine with me to deprecate it).  I prefer catching errors at compile-time
> with the new syntax.
>
> I've "overheard" some discussions in other circles about ditching all of
> signal/slot in favor of lambdas, and apologies for dragging that into the
> discussion.  It's something I've been thinking about a lot ...   ;-)

There are two things that the new syntax doesn't support: (i) QML
connections, and (ii) default parameters. I haven't used (ii) myself,
but I definitely use (i).

See http://doc.qt.io/qt-5/signalsandslots-syntaxes.html for details.


Regards,
Sze-Howe



More information about the Interest mailing list