Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QMetaMethod Class Reference

\inmodule QtCore More...

#include <qmetaobject.h>

+ Inheritance diagram for QMetaMethod:
+ Collaboration diagram for QMetaMethod:

Classes

struct  Data
 

Public Types

enum  Access { Private , Protected , Public }
 This enum describes the access level of a method, following the conventions used in C++. More...
 
enum  MethodType { Method , Signal , Slot , Constructor }
 \value Method The function is a plain member function. More...
 
enum  Attributes { Compatibility = 0x1 , Cloned = 0x2 , Scriptable = 0x4 }
 

Public Member Functions

constexpr QMetaMethod ()
 
QByteArray methodSignature () const
 
QByteArray name () const
 
const char * typeName () const
 Returns the return type name of this method.
 
int returnType () const
 
QMetaType returnMetaType () const
 
int parameterCount () const
 
int parameterType (int index) const
 
QMetaType parameterMetaType (int index) const
 
void getParameterTypes (int *types) const
 
QList< QByteArrayparameterTypes () const
 Returns a list of parameter types.
 
QByteArray parameterTypeName (int index) const
 
QList< QByteArrayparameterNames () const
 Returns a list of parameter names.
 
const char * tag () const
 Returns the tag associated with this method.
 
Access access () const
 Returns the access specification of this method (private, protected, or public).
 
MethodType methodType () const
 Returns the type of this method (signal, slot, or method).
 
int attributes () const
 
int methodIndex () const
 
int relativeMethodIndex () const
 
int revision () const
 
bool isConst () const
 
const QMetaObjectenclosingMetaObject () const
 
bool invoke (QObject *object, Qt::ConnectionType connectionType, QGenericReturnArgument returnValue, QGenericArgument val0=QGenericArgument(nullptr), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument()) const
 \obsolete [6.5] Please use the variadic overload of this function
 
bool invoke (QObject *object, QGenericReturnArgument returnValue, QGenericArgument val0=QGenericArgument(nullptr), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument()) const
 
bool invoke (QObject *object, Qt::ConnectionType connectionType, QGenericArgument val0, QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument()) const
 
bool invoke (QObject *object, QGenericArgument val0, QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument()) const
 
bool invokeOnGadget (void *gadget, QGenericReturnArgument returnValue, QGenericArgument val0=QGenericArgument(nullptr), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument()) const
 
bool invokeOnGadget (void *gadget, QGenericArgument val0, QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. \obsolete [6.5] Please use the variadic overload of this function.
 
template<typename ReturnArg , typename... Args>
QtPrivate::Invoke::IfNotOldStyleArgs< bool, Args... > invoke (QObject *obj, Qt::ConnectionType c, QTemplatedMetaMethodReturnArgument< ReturnArg > r, Args &&... arguments) const
 
template<typename... Args>
QtPrivate::Invoke::IfNotOldStyleArgs< bool, Args... > invoke (QObject *obj, Qt::ConnectionType c, Args &&... arguments) const
 
template<typename ReturnArg , typename... Args>
QtPrivate::Invoke::IfNotOldStyleArgs< bool, Args... > invoke (QObject *obj, QTemplatedMetaMethodReturnArgument< ReturnArg > r, Args &&... arguments) const
 
template<typename... Args>
QtPrivate::Invoke::IfNotOldStyleArgs< bool, Args... > invoke (QObject *obj, Args &&... arguments) const
 
template<typename ReturnArg , typename... Args>
QtPrivate::Invoke::IfNotOldStyleArgs< bool, Args... > invokeOnGadget (void *gadget, QTemplatedMetaMethodReturnArgument< ReturnArg > r, Args &&... arguments) const
 
template<typename... Args>
QtPrivate::Invoke::IfNotOldStyleArgs< bool, Args... > invokeOnGadget (void *gadget, Args &&... arguments) const
 
bool isValid () const
 

Static Public Member Functions

template<typename PointerToMemberFunction >
static QMetaMethod fromSignal (PointerToMemberFunction signal)
 

Protected Attributes

const QMetaObjectmobj
 
Data data
 

Friends

struct QMetaObject
 
struct QMetaObjectPrivate
 
class QObject
 
bool comparesEqual (const QMetaMethod &lhs, const QMetaMethod &rhs) noexcept
 

Related Symbols

(Note that these are not member symbols.)

QByteArray signature () const
 \macro Q_METAMETHOD_INVOKE_MAX_ARGS
 

Detailed Description

\inmodule QtCore

The QMetaMethod class provides meta-data about a member function.

\compares equality

A QMetaMethod has 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.

See also
QMetaObject, QMetaEnum, QMetaProperty, {Qt's Property System}

Definition at line 18 of file qmetaobject.h.

Member Enumeration Documentation

◆ Access

This enum describes the access level of a method, following the conventions used in C++.

\value Private \value Protected \value Public

Enumerator
Private 
Protected 
Public 

Definition at line 36 of file qmetaobject.h.

◆ Attributes

\value Compatibility \value Cloned \value Scriptable

Enumerator
Compatibility 
Cloned 
Scriptable 

Definition at line 40 of file qmetaobject.h.

◆ MethodType

\value Method The function is a plain member function.

\value Signal The function is a signal. \value Slot The function is a slot. \value Constructor The function is a constructor.

Enumerator
Method 
Signal 
Slot 
Constructor 

Definition at line 38 of file qmetaobject.h.

Constructor & Destructor Documentation

◆ QMetaMethod()

QMetaMethod::QMetaMethod ( )
inlineconstexpr

Definition at line 21 of file qmetaobject.h.

Member Function Documentation

◆ access()

QMetaMethod::Access QMetaMethod::access ( ) const

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
methodType()

Definition at line 2370 of file qmetaobject.cpp.

References AccessMask, and Private.

Referenced by QMetaObjectBuilder::addConstructor(), QMetaObjectBuilder::addMethod(), findSlot(), and generateInterfaceXml().

+ Here is the caller graph for this function:

◆ attributes()

int QMetaMethod::attributes ( ) const

Definition at line 2293 of file qmetaobject.cpp.

Referenced by QMetaObjectBuilder::addConstructor(), QMetaObjectBuilder::addMethod(), findSlot(), and generateInterfaceXml().

+ Here is the caller graph for this function:

◆ enclosingMetaObject()

const QMetaObject * QMetaMethod::enclosingMetaObject ( ) const
inline

Definition at line 47 of file qmetaobject.h.

Referenced by QDBusAdaptorConnector::relay().

+ Here is the caller graph for this function:

◆ fromSignal()

template<typename PointerToMemberFunction >
template< typename PointerToMemberFunction > QMetaMethod QMetaMethod::fromSignal ( PointerToMemberFunction signal)
inlinestatic

◆ getParameterTypes()

void QMetaMethod::getParameterTypes ( int * types) const
Since
5.0

Gets the parameter types of this method. The storage for types must be able to hold parameterCount() items.

See also
parameterCount(), returnType(), parameterType()

Definition at line 2200 of file qmetaobject.cpp.

◆ invoke() [1/8]

template<typename... Args>
template< typename... Args > bool QMetaMethod::invoke ( QObject * obj,
Args &&... arguments ) const
inline
Since
6.5

Invokes this method on the object object. Returns true if the member could be invoked. Returns false if there is no such member or the parameters did not match.

For the overloads with a QTemplatedMetaMethodReturnArgument parameter, the return value of the member function call is placed in ret. For the overloads without such a member, the return value of the called function (if any) will be discarded. QTemplatedMetaMethodReturnArgument is an internal type you should not use directly. Instead, use the qReturnArg() function.

The overloads with a Qt::ConnectionType type parameter allow explicitly selecting whether the invocation will be synchronous or not:

\list

  • If type is Qt::QueuedConnection, a QEvent will be sent and the member is invoked as soon as the application enters the event loop in the thread the obj was created in or was moved to.
  • If type is Qt::BlockingQueuedConnection, the method will be invoked in the same way as for Qt::QueuedConnection, except that the current thread will block until the event is delivered. Using this connection type to communicate between objects in the same thread will lead to deadlocks.
  • If type is Qt::AutoConnection, the member is invoked synchronously if obj lives in the same thread as the caller; otherwise it will invoke the member asynchronously. This is the behavior of the overloads that do not have the type parameter. \endlist

To asynchronously invoke the \l{QPushButton::animateClick()}{animateClick()} slot on a QPushButton:

int methodIndex = pushButton->metaObject()->indexOfMethod("animateClick()");
method.invoke(pushButton, Qt::QueuedConnection);

With asynchronous method invocations, the parameters must be copyable types, because Qt needs to copy the arguments to store them in an event behind the scenes. Since Qt 6.5, this function automatically registers the types being used; however, as a side-effect, it is not possible to make calls using types that are only forward-declared. Additionally, it is not possible to make asynchronous calls that use references to non-const-qualified types as parameters either.

To synchronously invoke the compute(QString, int, double) slot on some arbitrary object obj retrieve its return value:

QString retVal;
QByteArray normalizedSignature = QMetaObject::normalizedSignature("compute(QString, int, double)");
int methodIndex = obj->metaObject()->indexOfMethod(normalizedSignature);
QMetaMethod method = obj->metaObject()->method(methodIndex);
method.invoke(obj, Qt::DirectConnection, qReturnArg(retVal),
QString("sqrt"), 42, 9.7);

If the "compute" slot does not take exactly one \l QString, one int, and one double in the specified order, the call will fail. Note how it was necessary to be explicit about the type of the QString, as the character literal is not exactly the right type to match. If the method instead took a \l QByteArray, a \l qint64, and a {long double}, the call would need to be written as:

QString retVal;
QByteArray normalizedSignature = QMetaObject::normalizedSignature("compute(QByteArray, qint64, long double)");
int methodIndex = obj->metaObject()->indexOfMethod(normalizedSignature);
QMetaMethod method = obj->metaObject()->method(methodIndex);
method.invoke(obj, Qt::DirectConnection, qReturnArg(retVal),
QByteArray("sqrt"), qint64(42), 9.7L);

The same call can be executed using the Q_ARG() and Q_RETURN_ARG() macros, as in:

QString retVal;
QByteArray normalizedSignature = QMetaObject::normalizedSignature("compute(QString, int, double)");
int methodIndex = obj->metaObject()->indexOfMethod(normalizedSignature);
QMetaMethod method = obj->metaObject()->method(methodIndex);
method.invoke(obj,
Qt::DirectConnection,
Q_ARG(QString, "sqrt"),
Q_ARG(int, 42),
Q_ARG(double, 9.7));
Warning
this method will not test the validity of the arguments: object must be an instance of the class of the QMetaObject of which this QMetaMethod has been constructed with.
See also
Q_ARG(), Q_RETURN_ARG(), qRegisterMetaType(), QMetaObject::invokeMethod()

Definition at line 181 of file qmetaobject.h.

References arguments, and Qt::AutoConnection.

◆ invoke() [2/8]

template<typename... Args>
template< typename... Args > bool QMetaMethod::invoke ( QObject * obj,
Qt::ConnectionType c,
Args &&... arguments ) const
inline

Definition at line 159 of file qmetaobject.h.

References arguments.

◆ invoke() [3/8]

template<typename ReturnArg , typename... Args>
template< typename ReturnArg, typename... Args > bool QMetaMethod::invoke ( QObject * obj,
Qt::ConnectionType c,
QTemplatedMetaMethodReturnArgument< ReturnArg > r,
Args &&... arguments ) const
inline

Definition at line 145 of file qmetaobject.h.

References arguments, and QtPrivate::invokeMethodHelper().

+ Here is the call graph for this function:

◆ invoke() [4/8]

template<typename ReturnArg , typename... Args>
template< typename ReturnArg, typename... Args > bool QMetaMethod::invoke ( QObject * obj,
QTemplatedMetaMethodReturnArgument< ReturnArg > r,
Args &&... arguments ) const
inline

Definition at line 170 of file qmetaobject.h.

References arguments, and Qt::AutoConnection.

◆ invoke() [5/8]

◆ invoke() [6/8]

◆ invoke() [7/8]

◆ invoke() [8/8]

\obsolete [6.5] Please use the variadic overload of this function

Invokes this method on the object object. Returns true if the member could be invoked. Returns false if 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:

\list

  • The number of parameters is limited to 10.
  • Parameter names may need to be an exact string match.
  • Meta types are not automatically registered. \endlist

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

call qRegisterMetaType() to register the data type before you call QMetaMethod::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(), QMetaObject::invokeMethod()

Definition at line 2533 of file qmetaobject.cpp.

References MaximumParamCount, and qstrlen().

Referenced by QTextDocument::loadResource(), AVFCameraRenderer::syncHandleViewfinderFrame(), QQuick3DTexture::updateSpatialNode(), and wrapInFunction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ invokeOnGadget() [1/4]

template<typename... Args>
template< typename... Args > bool QMetaMethod::invokeOnGadget ( void * gadget,
Args &&... arguments ) const
inline
Since
6.5

Invokes this method on a Q_GADGET. Returns true if the member could be invoked. Returns false if there is no such member or the parameters did not match.

The pointer gadget must point to an instance of the gadget class.

The invocation is always synchronous.

For the overload with a QTemplatedMetaMethodReturnArgument parameter, the return value of the member function call is placed in ret. For the overload without it, the return value of the called function (if any) will be discarded. QTemplatedMetaMethodReturnArgument is an internal type you should not use directly. Instead, use the qReturnArg() function.

Warning
this method will not test the validity of the arguments: gadget must be an instance of the class of the QMetaObject of which this QMetaMethod has been constructed with.
See also
Q_ARG(), Q_RETURN_ARG(), qRegisterMetaType(), QMetaObject::invokeMethod()

Definition at line 205 of file qmetaobject.h.

References arguments.

◆ invokeOnGadget() [2/4]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. \obsolete [6.5] Please use the variadic overload of this function.

Since
5.5

This overload invokes this method for a gadget and ignores return values.

Definition at line 122 of file qmetaobject.h.

◆ invokeOnGadget() [3/4]

Since
5.5 \obsolete [6.5] Please use the variadic overload of this function

Invokes this method on a Q_GADGET. Returns true if the member could be invoked. Returns false if 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:

\list

  • The number of parameters is limited to 10.
  • Parameter names may need to be an exact string match.
  • Meta types are not automatically registered. \endlist
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(), QMetaObject::invokeMethod()

Definition at line 2910 of file qmetaobject.cpp.

References QMetaObject::d, QMetaType::fromName(), QMetaObjectPrivate::get(), QMetaObject::InvokeMetaMethod, MaximumParamCount, QMetaObject::normalizedType(), Q_ASSERT, qstrcmp(), qstrlen(), typeName, and QMetaType::UnknownType.

+ Here is the call graph for this function:

◆ invokeOnGadget() [4/4]

template<typename ReturnArg , typename... Args>
template< typename ReturnArg, typename... Args > bool QMetaMethod::invokeOnGadget ( void * gadget,
QTemplatedMetaMethodReturnArgument< ReturnArg > r,
Args &&... arguments ) const
inline

Definition at line 192 of file qmetaobject.h.

References arguments, and QtPrivate::invokeMethodHelper().

+ Here is the call graph for this function:

◆ isConst()

bool QMetaMethod::isConst ( ) const
Since
6.2

Returns whether the method is const qualified.

Note
This method might erroneously return false for a const method if it belongs to a library compiled against an older version of Qt.

Definition at line 2351 of file qmetaobject.cpp.

References QMetaObjectPrivate::get(), and MethodIsConst.

+ Here is the call graph for this function:

◆ isValid()

bool QMetaMethod::isValid ( ) const
inline
Since
5.0

Returns true if this method is valid (can be introspected and invoked), otherwise returns false.

Definition at line 210 of file qmetaobject.h.

Referenced by QQuick3DTexture::QQuick3DTexture(), QV4::QQmlValueTypeWrapper::dataForPropertyKey(), QTest::qSignalDumperCallback(), and QTest::qSignalDumperCallbackSlot().

+ Here is the caller graph for this function:

◆ methodIndex()

int QMetaMethod::methodIndex ( ) const
Since
4.6

Returns this method's index.

Definition at line 2305 of file qmetaobject.cpp.

References QMetaObject::methodOffset().

+ Here is the call graph for this function:

◆ methodSignature()

QByteArray QMetaMethod::methodSignature ( ) const
Since
5.0

Returns the signature of this method (e.g., {setValue(double)}).

See also
parameterTypes(), parameterNames()

Definition at line 2083 of file qmetaobject.cpp.

References QByteArray().

Referenced by QMetaObjectBuilder::addConstructor(), QMetaObjectBuilder::addMethod(), QQmlProperty::connectNotifySignal(), QObject::dumpObjectInfo(), QQmlVMEMetaObject::metaCall(), QTest::qPrintDataTags(), QTest::qSignalDumperCallbackSlot(), QDBusAdaptorConnector::relay(), and QDBusAbstractAdaptor::setAutoRelaySignals().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ methodType()

QMetaMethod::MethodType QMetaMethod::methodType ( ) const

Returns the type of this method (signal, slot, or method).

See also
access()

Definition at line 2382 of file qmetaobject.cpp.

References Method, and MethodTypeMask.

Referenced by QMetaObjectBuilder::addConstructor(), QMetaObjectBuilder::addMethod(), findSlot(), QDBusAbstractInterfacePrivate::finishDisconnectNotify(), generateInterfaceXml(), QMetaObjectPrivate::memberIndexes(), QDBusInterfacePrivate::metacall(), and QDBusAbstractAdaptor::setAutoRelaySignals().

+ Here is the caller graph for this function:

◆ name()

QByteArray QMetaMethod::name ( ) const
Since
5.0

Returns the name of this method.

See also
methodSignature(), parameterCount()

Definition at line 2097 of file qmetaobject.cpp.

References QByteArray().

Referenced by QDBusAbstractInterface::callWithArgumentList(), findSlot(), generateInterfaceXml(), QDBusInterfacePrivate::metacall(), and QTest::qSignalDumperCallback().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parameterCount()

int QMetaMethod::parameterCount ( ) const
Since
5.0

Returns the number of parameters of this method.

See also
parameterType(), parameterNames()

Definition at line 2143 of file qmetaobject.cpp.

Referenced by QQmlBoundSignalExpression::evaluate(), and qDBusParametersForMethod().

+ Here is the caller graph for this function:

◆ parameterMetaType()

QMetaType QMetaMethod::parameterMetaType ( int index) const
Since
6.0

Returns the metatype of the parameter at the given index.

If the index is smaller than zero or larger than parameterCount(), an invalid QMetaType is returned.

See also
parameterCount(), returnMetaType(), QMetaType

Definition at line 2175 of file qmetaobject.cpp.

References Constructor, QMetaObject::d, priv(), and QMetaType::UnknownType.

Referenced by QQmlBoundSignalExpression::evaluate(), and qDBusParametersForMethod().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parameterNames()

QList< QByteArray > QMetaMethod::parameterNames ( ) const

Returns a list of parameter names.

See also
parameterTypes(), methodSignature()

Definition at line 2238 of file qmetaobject.cpp.

Referenced by QMetaObjectBuilder::addConstructor(), QMetaObjectBuilder::addMethod(), and generateInterfaceXml().

+ Here is the caller graph for this function:

◆ parameterType()

int QMetaMethod::parameterType ( int index) const
Since
5.0

Returns the type of the parameter at the given index.

The return value is one of the types that are registered with QMetaType, or QMetaType::UnknownType if the type is not registered.

See also
parameterCount(), parameterMetaType(), returnType(), QMetaType

Definition at line 2160 of file qmetaobject.cpp.

◆ parameterTypeName()

QByteArray QMetaMethod::parameterTypeName ( int index) const
Since
6.0 Returns the name of the type at position index If there is no parameter at index, returns an empty QByteArray
See also
parameterNames()

Definition at line 2226 of file qmetaobject.cpp.

Referenced by qDBusParametersForMethod().

+ Here is the caller graph for this function:

◆ parameterTypes()

QList< QByteArray > QMetaMethod::parameterTypes ( ) const

Returns a list of parameter types.

See also
parameterNames(), methodSignature()

Definition at line 2212 of file qmetaobject.cpp.

Referenced by QTest::qSignalDumperCallback().

+ Here is the caller graph for this function:

◆ relativeMethodIndex()

int QMetaMethod::relativeMethodIndex ( ) const
Since
6.0

Returns this method's local index inside.

Definition at line 2317 of file qmetaobject.cpp.

Referenced by QMetaObjectPrivate::memberIndexes().

+ Here is the caller graph for this function:

◆ returnMetaType()

QMetaType QMetaMethod::returnMetaType ( ) const
Since
6.0

Returns the return type of this method.

See also
parameterMetaType(), QMetaType, typeName()

Definition at line 2125 of file qmetaobject.cpp.

References Constructor, QMetaObject::d, and QMetaType::UnknownType.

Referenced by findSlot(), generateInterfaceXml(), and QQmlMetaObject::methodReturnType().

+ Here is the caller graph for this function:

◆ returnType()

int QMetaMethod::returnType ( ) const
Since
5.0

Returns the return type of this method.

The return value is one of the types that are registered with QMetaType, or QMetaType::UnknownType if the type is not registered.

See also
parameterType(), QMetaType, typeName(), returnMetaType()

Definition at line 2114 of file qmetaobject.cpp.

Referenced by QDBusInterfacePrivate::metacall().

+ Here is the caller graph for this function:

◆ revision()

int QMetaMethod::revision ( ) const
Since
5.1 Returns the method revision if one was specified by Q_REVISION, otherwise returns 0.

Definition at line 2330 of file qmetaobject.cpp.

References QMetaObject::d, MethodRevisioned, and priv().

Referenced by QMetaObjectBuilder::addMethod().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tag()

const char * QMetaMethod::tag ( ) const

Returns the tag associated with this method.

Tags are special macros recognized by moc that 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.show();
int functionIndex = win.metaObject()->indexOfSlot("testFunc()");
QMetaMethod mm = win.metaObject()->method(functionIndex);
qDebug() << mm.tag(); // prints MY_CUSTOM_TAG

For the moment, moc will 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
moc expands preprocessor macros, so it is necessary to surround the definition with #ifndef Q_MOC_RUN, as shown in the example above.

Definition at line 2282 of file qmetaobject.cpp.

Referenced by QMetaObjectBuilder::addConstructor(), QMetaObjectBuilder::addMethod(), QDBusAbstractInterface::callWithArgumentList(), findSlot(), generateInterfaceXml(), and wrapInFunction().

+ Here is the caller graph for this function:

◆ typeName()

const char * QMetaMethod::typeName ( ) const

Returns the return type name of this method.

See also
returnType(), QMetaType::type()

Definition at line 2251 of file qmetaobject.cpp.

Referenced by QMetaObjectBuilder::addConstructor(), QMetaObjectBuilder::addMethod(), and QQmlMetaObject::methodReturnType().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ comparesEqual

bool comparesEqual ( const QMetaMethod & lhs,
const QMetaMethod & rhs )
friend

Definition at line 257 of file qmetaobject.h.

◆ QMetaObject

friend struct QMetaObject
friend

Definition at line 252 of file qmetaobject.h.

◆ QMetaObjectPrivate

friend struct QMetaObjectPrivate
friend

Definition at line 253 of file qmetaobject.h.

◆ QObject

friend class QObject
friend

Definition at line 254 of file qmetaobject.h.

◆ signature()

QByteArray signature ( ) const
related

\macro Q_METAMETHOD_INVOKE_MAX_ARGS

Equals maximum number of arguments available for execution of the method via QMetaMethod::invoke()

Definition at line 1893 of file qmetaobject.cpp.

References QMetaObject::d, i, priv(), and Q_ASSERT.

+ Here is the call graph for this function:

Member Data Documentation

◆ data

Data QMetaMethod::data
protected

Definition at line 251 of file qmetaobject.h.

◆ mobj

const QMetaObject* QMetaMethod::mobj
protected

Definition at line 250 of file qmetaobject.h.

Referenced by QMetaObjectPrivate::memberIndexes().


The documentation for this class was generated from the following files: