[Interest] Qt5 connect signal to signal

Jérôme Godbout godboutj at amotus.ca
Tue Mar 10 14:21:11 CET 2020


This should work, the default is connect type auto, which mean that it will be direct if both object (source and this in your example) have the same thread affinity. If both have a different thread affinity, the connection will be queued. Note, on queued signal, argument must be copiable and take care of QObject* that must survive and have the proper thread affinity if used. You can verify the QObject thread affinity with the following call:
https://doc.qt.io/qt-5/qobject.html#thread

queued connection if source->thread() != this->thread()
direct connection if source->thread() == this->thread()

You can also enforce the connection type, but normally auto is doing the right thing, unless you moveToThread() after the connection.


-----Original Message-----
From: Interest <interest-bounces at qt-project.org> On Behalf Of Hamish Moffatt
Sent: March 10, 2020 1:27 AM
To: interest at qt-project.org
Subject: [Interest] Qt5 connect signal to signal

In the old syntax one could:

connect(source, SIGNAL(readProgress(int)), SIGNAL(progress(int)));


In the new syntax, is it equivalent to use

connect(source, &SourceClass::readProgress, this, &ThisClass::progress);

... assuming that all of this is on a single thread?


I'm not quite clear what thread context the first is using when repeating the signal?


Hamish

_______________________________________________
Interest mailing list
Interest at qt-project.org
https://lists.qt-project.org/listinfo/interest


More information about the Interest mailing list