Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2500

invokeMethod or QMetaMethod->invoke() not possible for more than 3 arguments

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.6.1
    • 6.5.2
    • PySide
    • None
    • All
    • 22128c3d6 (dev), dfbf93571 (dev), 824937e58 (dev), f742e2195 (6.6), a636c056c (6.6), c4b54f9ac (6.6)

    Description

      I noticed the following when trying to invoke object methods directly from PySide6 using QMetaObject::invokeMethod() and QMetaMethod::invoke() in a generic way. The context is to call an abitrary method this way, which may have various return types:

       

      • Q_ARG and Q_RETURN_ARG yield QGeneric[Return]ArgumentHolders, respectively. There is no direct method to get the Pythonic value back out of these structures.
      • The Holders can be converted to QGenericArgument and QGenericReturnArgument (which we also can't get the Pythonic value back out of).
      • QMetaObject::invokeMethod with the ...Holder types offers exactly what I need here: a way to call a method and yield an arbitrary Python object (converts the generic return argument back to the correct Pythonic object type under the hood"). But:
        • This invokeMethod variant only allows for max. 3 arguments to be passed, whereas the non-...Holder variants offer up to about 10.
        • FYI, the return arg conversion is implemented in 
          static PyObject *invokeMethodHelper (qtcore.cpp)
        • This seems to be the only method in the PySide API that does this automatic conversion.
      • QMetaMethod::invoke doesn't have any interface which offers the automatic return type conversion.

       

      Thus, it seems to me it is not possible to invoke a method generically if it has more than 3 arguments and a return value.

       

      My suggestion would be to offer a direct conversion function which takes a QGeneric[Return]Argument and yields the correct Python value. Basically implementing the same conversion which is already being done now in static PyObject *invokeMethodHelper (qtcore.cpp).

      This way, it can also be used with QMetaMethod, which I am assuming is faster than invokeMethod by name.

       

       

      Attachments

        Issue Links

          For Gerrit Dashboard: PYSIDE-2500
          # Subject Branch Project Status CR V

          Activity

            People

              kleint Friedemann Kleint
              narcoticv Sander Vocke
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes