Solved How does Qt::connectiontype work?
I have this:
QObject::connect(m_communicationCenter, &communicationCenter::globalCalRequested, m_motorCenter, &motorCenter::globalCalRequired, static_cast<Qt::ConnectionType>(Qt::UniqueConnection | Qt::DirectConnection));
Yes, it is disgustingly long...
Does this multiple connection type mean that the slot is going to be invoque only once directly on the thread of its QObject?
KillerSmath last edited by
By default, a signal is emitted for every connection you make;
two signals are emitted for duplicate connections. You can break
all of these connections with a single disconnect() call.
If you pass the Qt::UniqueConnection type, the connection will only
be made if it is not a duplicate. If there is already a duplicate
(exact same signal to the exact same slot on the same objects),
the connection will fail and connect will return an invalid QMetaObject::Connection.
\note Qt::UniqueConnections do not work for lambdas, non-member functions
and functors; they only apply to connecting to member functions.
Thank you, but I understand the principe of the unique connection. My question was about how passing two connection type like I've done is interpreted. Will it be a direct connection that cannot be duplicated or something else?
From the doc:
This is a flag that can be combined with any one of the above connection types, using a bitwise OR. When Qt::UniqueConnection is set, QObject::connect() will fail if the connection already exists (i.e. if the same signal is already connected to the same slot for the same pair of objects). This flag was introduced in Qt 4.6.
So yes, you can combine that flag with one of the others.