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

Signal QMetaMethod connection to parameter-less lambda

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • Core: Object Model
    • 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

        For Gerrit Dashboard: QTBUG-120631
        # Subject Branch Project Status CR V

        Activity

          People

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

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There is 1 open Gerrit change