PySide6.QtCore.QMetaMethod¶
- class QMetaMethod¶
- The - QMetaMethodclass provides meta-data about a member function. More…- Synopsis¶- Methods¶- def - __init__()
- def - access()
- def - invoke()
- def - invokeOnGadget()
- def - isConst()
- def - isValid()
- def - methodIndex()
- def - methodType()
- def - name()
- def - __ne__()
- def - __eq__()
- def - parameterCount()
- def - parameterNames()
- def - parameterType()
- def - parameterTypes()
- def - returnMetaType()
- def - returnType()
- def - revision()
- def - tag()
- def - typeName()
 - Static functions¶- def - fromSignal()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- A - QMetaMethodhas a- methodType(), a- methodSignature(), a list of- parameterTypes()and- parameterNames(), a return- typeName(), a- tag(), and an- access()specifier. You can use- invoke()to invoke the method on an arbitrary- QObject.- class Access¶
- This enum describes the access level of a method, following the conventions used in C++. - Constant - Description - QMetaMethod.Private - QMetaMethod.Protected - QMetaMethod.Public 
 - class MethodType¶
- Constant - Description - QMetaMethod.Method - The function is a plain member function. - QMetaMethod.Signal - The function is a signal. - QMetaMethod.Slot - The function is a slot. - QMetaMethod.Constructor - The function is a constructor. 
 - __init__()¶
 - Returns the access specification of this method (private, protected, or public). - Note - Signals are always public, but you should regard that as an implementation detail. It is almost always a bad idea to emit a signal from outside its class. - See also - enclosingMetaObject()¶
- Return type:
 
 - static fromSignal(signal)¶
- Parameters:
- signal – - PySideSignalInstance
- Return type:
 
 - Returns the meta-method that corresponds to the given signal, or an invalid QMetaMethod if signal is not a signal of the class. - invoke(object, val0[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]])¶
- Parameters:
- object – - QObject
- val0 – - QGenericArgument
- val1 – - QGenericArgument
- val2 – - QGenericArgument
- val3 – - QGenericArgument
- val4 – - QGenericArgument
- val5 – - QGenericArgument
- val6 – - QGenericArgument
- val7 – - QGenericArgument
- val8 – - QGenericArgument
- val9 – - QGenericArgument
 
- Return type:
- bool 
 
 - Please use the variadic overload of this function - This function overloads - invoke().- This overload invokes this method using the connection type - AutoConnectionand ignores return values.- invoke(object[, val0={}[, val1={}[, val2={}[, val3={}[, val4={}[, val5={}[, val6={}[, val7={}[, val8={}[, val9={}]]]]]]]]]])
- Parameters:
- object – - QObject
- val0 – - QGenericArgumentHolder
- val1 – - QGenericArgumentHolder
- val2 – - QGenericArgumentHolder
- val3 – - QGenericArgumentHolder
- val4 – - QGenericArgumentHolder
- val5 – - QGenericArgumentHolder
- val6 – - QGenericArgumentHolder
- val7 – - QGenericArgumentHolder
- val8 – - QGenericArgumentHolder
- val9 – - QGenericArgumentHolder
 
- Return type:
- object 
 
 - invoke(object, returnValue[, val0=QGenericArgument(nullptr)[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]]])
- Parameters:
- object – - QObject
- returnValue – - QGenericReturnArgument
- val0 – - QGenericArgument
- val1 – - QGenericArgument
- val2 – - QGenericArgument
- val3 – - QGenericArgument
- val4 – - QGenericArgument
- val5 – - QGenericArgument
- val6 – - QGenericArgument
- val7 – - QGenericArgument
- val8 – - QGenericArgument
- val9 – - QGenericArgument
 
- Return type:
- bool 
 
 - Please use the variadic overload of this function - This function overloads - invoke().- This overload always invokes this method using the connection type - AutoConnection.- invoke(object, connectionType, val0[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]])
- Parameters:
- object – - QObject
- connectionType – - ConnectionType
- val0 – - QGenericArgument
- val1 – - QGenericArgument
- val2 – - QGenericArgument
- val3 – - QGenericArgument
- val4 – - QGenericArgument
- val5 – - QGenericArgument
- val6 – - QGenericArgument
- val7 – - QGenericArgument
- val8 – - QGenericArgument
- val9 – - QGenericArgument
 
- Return type:
- bool 
 
 - Please use the variadic overload of this function - This function overloads - invoke().- This overload can be used if the return value of the member is of no interest. - invoke(object, type[, val0={}[, val1={}[, val2={}[, val3={}[, val4={}[, val5={}[, val6={}[, val7={}[, val8={}[, val9={}]]]]]]]]]])
- Parameters:
- object – - QObject
- type – - ConnectionType
- val0 – - QGenericArgumentHolder
- val1 – - QGenericArgumentHolder
- val2 – - QGenericArgumentHolder
- val3 – - QGenericArgumentHolder
- val4 – - QGenericArgumentHolder
- val5 – - QGenericArgumentHolder
- val6 – - QGenericArgumentHolder
- val7 – - QGenericArgumentHolder
- val8 – - QGenericArgumentHolder
- val9 – - QGenericArgumentHolder
 
- Return type:
- object 
 
 - invoke(object, ret[, val0={}[, val1={}[, val2={}[, val3={}[, val4={}[, val5={}[, val6={}[, val7={}[, val8={}[, val9={}]]]]]]]]]])
- Parameters:
- object – - QObject
- ret – - QGenericReturnArgumentHolder
- val0 – - QGenericArgumentHolder
- val1 – - QGenericArgumentHolder
- val2 – - QGenericArgumentHolder
- val3 – - QGenericArgumentHolder
- val4 – - QGenericArgumentHolder
- val5 – - QGenericArgumentHolder
- val6 – - QGenericArgumentHolder
- val7 – - QGenericArgumentHolder
- val8 – - QGenericArgumentHolder
- val9 – - QGenericArgumentHolder
 
- Return type:
- object 
 
 - invoke(object, connectionType, returnValue[, val0=QGenericArgument(nullptr)[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]]])
- Parameters:
- object – - QObject
- connectionType – - ConnectionType
- returnValue – - QGenericReturnArgument
- val0 – - QGenericArgument
- val1 – - QGenericArgument
- val2 – - QGenericArgument
- val3 – - QGenericArgument
- val4 – - QGenericArgument
- val5 – - QGenericArgument
- val6 – - QGenericArgument
- val7 – - QGenericArgument
- val8 – - QGenericArgument
- val9 – - QGenericArgument
 
- Return type:
- bool 
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Please use the variadic overload of this function - Invokes this method on the object - object. Returns- trueif the member could be invoked. Returns- falseif there is no such member or the parameters did not match.- See the variadic invokeMethod() function for more information. This function should behave the same way as that one, with the following limitations: - The number of parameters is limited to 10. 
- Parameter names may need to be an exact string match. 
- Meta types are not automatically registered. 
 - With asynchronous method invocations, the parameters must be of types that are known to Qt’s meta-object system, because Qt needs to copy the arguments to store them in an event behind the scenes. If you try to use a queued connection and get the error message - QMetaMethod.invoke: Unable to handle unregistered datatype 'MyType' - call - qRegisterMetaType()to register the data type before you call- invoke().- Warning - In addition to the limitations of the variadic - invoke()overload, the arguments must have the same type as the ones expected by the method, else, the behavior is undefined.- See also - Q_ARG()- Q_RETURN_ARG()- qRegisterMetaType()- invokeMethod()- invoke(object, type, ret[, val0={}[, val1={}[, val2={}[, val3={}[, val4={}[, val5={}[, val6={}[, val7={}[, val8={}[, val9={}]]]]]]]]]])
- Parameters:
- object – - QObject
- type – - ConnectionType
- ret – - QGenericReturnArgumentHolder
- val0 – - QGenericArgumentHolder
- val1 – - QGenericArgumentHolder
- val2 – - QGenericArgumentHolder
- val3 – - QGenericArgumentHolder
- val4 – - QGenericArgumentHolder
- val5 – - QGenericArgumentHolder
- val6 – - QGenericArgumentHolder
- val7 – - QGenericArgumentHolder
- val8 – - QGenericArgumentHolder
- val9 – - QGenericArgumentHolder
 
- Return type:
- object 
 
 - invokeOnGadget(gadget, val0[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]])¶
- Parameters:
- gadget – - void
- val0 – - QGenericArgument
- val1 – - QGenericArgument
- val2 – - QGenericArgument
- val3 – - QGenericArgument
- val4 – - QGenericArgument
- val5 – - QGenericArgument
- val6 – - QGenericArgument
- val7 – - QGenericArgument
- val8 – - QGenericArgument
- val9 – - QGenericArgument
 
- Return type:
- bool 
 
 - This is an overloaded function. - Please use the variadic overload of this function - This overload invokes this method for a - gadgetand ignores return values.- invokeOnGadget(gadget, returnValue[, val0=QGenericArgument(nullptr)[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]]])
- Parameters:
- gadget – - void
- returnValue – - QGenericReturnArgument
- val0 – - QGenericArgument
- val1 – - QGenericArgument
- val2 – - QGenericArgument
- val3 – - QGenericArgument
- val4 – - QGenericArgument
- val5 – - QGenericArgument
- val6 – - QGenericArgument
- val7 – - QGenericArgument
- val8 – - QGenericArgument
- val9 – - QGenericArgument
 
- Return type:
- bool 
 
 - Please use the variadic overload of this function - Invokes this method on a - Q_GADGET. Returns- trueif the member could be invoked. Returns- falseif there is no such member or the parameters did not match.- See the variadic invokeMethod() function for more information. This function should behave the same way as that one, with the following limitations: - The number of parameters is limited to 10. 
- Parameter names may need to be an exact string match. 
- Meta types are not automatically registered. 
 - Warning - In addition to the limitations of the variadic - invoke()overload, the arguments must have the same type as the ones expected by the method, else, the behavior is undefined.- See also - Q_ARG()- Q_RETURN_ARG()- qRegisterMetaType()- invokeMethod()- isConst()¶
- Return type:
- bool 
 
 - Returns whether the method is const qualified. - Note - This method might erroneously return - falsefor a const method if it belongs to a library compiled against an older version of Qt.- isValid()¶
- Return type:
- bool 
 
 - Returns - trueif this method is valid (can be introspected and invoked), otherwise returns- false.- methodIndex()¶
- Return type:
- int 
 
 - Returns this method’s index. - methodSignature()¶
- Return type:
 
 - Returns the signature of this method (e.g., - setValue(double)).- See also - methodType()¶
- Return type:
 
 - Returns the type of this method (signal, slot, or method). - See also - name()¶
- Return type:
 
 - Returns the name of this method. - See also - __ne__(rhs)¶
- Parameters:
- rhs – - QMetaMethod
- Return type:
- bool 
 
 - This is an overloaded function. - Returns - trueif method- lhsis not equal to method- rhs, otherwise returns- false.- __eq__(rhs)¶
- Parameters:
- rhs – - QMetaMethod
- Return type:
- bool 
 
 - This is an overloaded function. - Returns - trueif method- lhsis equal to method- rhs, otherwise returns- false.- parameterCount()¶
- Return type:
- int 
 
 - Returns the number of parameters of this method. - See also - Returns the metatype of the parameter at the given - index.- If the - indexis smaller than zero or larger than- parameterCount(), an invalid- QMetaTypeis returned.- See also - parameterNames()¶
- Return type:
- .list of QByteArray 
 
 - Returns a list of parameter names. - See also - parameterType(index)¶
- Parameters:
- index – int 
- Return type:
- int 
 
 - Returns the type of the parameter at the given - index.- The return value is one of the types that are registered with - QMetaType, or- UnknownTypeif the type is not registered.- parameterTypeName(index)¶
- Parameters:
- index – int 
- Return type:
 
 - Returns the name of the type at position - indexIf there is no parameter at- index, returns an empty- QByteArray- See also - parameterTypes()¶
- Return type:
- .list of QByteArray 
 
 - Returns a list of parameter types. - See also - relativeMethodIndex()¶
- Return type:
- int 
 
 - Returns this method’s local index inside. - Returns the return type of this method. - See also - returnType()¶
- Return type:
- int 
 
 - Returns the return type of this method. - The return value is one of the types that are registered with - QMetaType, or- UnknownTypeif the type is not registered.- revision()¶
- Return type:
- int 
 
 - Returns the method revision if one was specified by - Q_REVISION, otherwise returns 0. Since Qt 6.0, non-zero values are encoded and can be decoded using- fromEncodedVersion().- tag()¶
- Return type:
- str 
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Returns the tag associated with this method. - Tags are special macros recognized by - mocthat make it possible to add extra information about a method.- Tag information can be added in the following way in the function declaration: - # In the class MainWindow declaration #ifndef Q_MOC_RUN # define the tag text as empty, so the compiler doesn't see it # define MY_CUSTOM_TAG #endif ... # private slots MY_CUSTOM_TAG void testFunc() - and the information can be accessed by using: - win = MainWindow() win.show() functionIndex = win.metaObject().indexOfSlot("testFunc()") mm = win.metaObject().method(functionIndex) print(mm.tag()) # prints MY_CUSTOM_TAG - For the moment, - mocwill extract and record all tags, but it will not handle any of them specially. You can use the tags to annotate your methods differently, and treat them according to the specific needs of your application.- Note - mocexpands preprocessor macros, so it is necessary to surround the definition with- #ifndef- Q_MOC_RUN, as shown in the example above.- typeName()¶
- Return type:
- str 
 
 - Returns the return type name of this method. - See also