Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
None
-
None
Description
I believe it would be valuable for code using QMetaObject introspection to be able to connect a signal QMetaMethod to a parameter-less lambda capturing some context.
Depending on the use-case, some workaround are possible but they are less than desirable. One is to connect to a parameter less function and then using QObject::sender and senderSignalIndex if that maps to what you wanted to capture, but that's pretty expensive because it has to lock an internal mutex. Another is to use one or multiple QSignalMapper if applicable. A last resort solution is to use a custom "light" signal mapper, an obscure example can be found in quick/items/qquickshadereffect.cpp with EffectSlotMapper.
Some real world use-cases that could benefit from it are also mentioned in the comments of https://bugreports.qt.io/browse/QTBUG-73407
Attachments
Issue Links
- is duplicated by
-
QTBUG-132493 Allow SIGNAL() and SLOT() to be used with QMetaObject::indexOfSignal() and QMetaObject::indexOfSlot()
- Open
Gerrit Reviews
For Gerrit Dashboard: QTBUG-120631 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
557855,11 | Add a QObject::connect overload for QMetaMethod to PMF/Functor | dev | qt/qtbase | Status: NEW | 0 | 0 |