Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-120631

Signal QMetaMethod connection to parameter-less lambda

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Fixed
    • Icon: Not Evaluated Not Evaluated
    • 6.10.0 FF
    • None
    • Core: Object Model
    • None
    • d8b4eb1a1 (dev)

      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

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            cnn Qt Core & Network
            grecko Pierre-Yves Siret
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes