Static(ly-typed) queued connections for Qt signals.
- arguments can be any copyable types, i.e.:
- no type registration needed (
Q_DECLARE_METATYPE
,qRegisterMetaType()
etc.); - no default constructors required;
- no type registration needed (
- slightly faster (no per-argument memory allocations);
- argument types in signal declarations do not need to be namespace-qualified.
- receivers must not change their thread affinity while any
squco
-connections any active, undefined behaviour otherwise; - error messages on incompatible parameters may be worse than from
QObject::connect()
;
- C++14;
- Qt5 (tested on Qt 5.9.1)
Similar to the standard 4-argument QObject::connect()
:
To connect:
squco::connectSlot(f, &From::signalX, t, &To::slotY);
squco::connectFunctor(f, &From::signalX, t, [t, otherParam]{ t->abc(5, otherParam); });
To disconnect:
auto conn = squco::connectSlot(...);
...
QObject::disconnect(conn);
Naturally, squco
always assumes Qt::QueuedConnection
.
Not yet tested in production. Reports welcome.
See unit tests in test.cpp
.
MIT