Qt 4.8
|
The QMetaMethod class provides meta-data about a member function. More...
#include <qmetaobject.h>
Public Types | |
enum | Access { Private, Protected, Public } |
This enum describes the access level of a method, following the conventions used in C++. More... | |
enum | Attributes { Compatibility = 0x1, Cloned = 0x2, Scriptable = 0x4 } |
enum | MethodType { Method, Signal, Slot, Constructor } |
Properties | |
uint | handle |
const QMetaObject * | mobj |
Friends | |
struct | QMetaObject |
struct | QMetaObjectPrivate |
class | QObject |
The QMetaMethod class provides meta-data about a member function.
A QMetaMethod has a methodType(), a signature(), 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.
A method will only be registered with the meta-object system if it is a slot, a signal, or declared with the Q_INVOKABLE macro. Constructors can also be registered with Q_INVOKABLE.
Definition at line 56 of file qmetaobject.h.
enum QMetaMethod::Access |
This enum describes the access level of a method, following the conventions used in C++.
Enumerator | |
---|---|
Private | |
Protected | |
Public |
Definition at line 66 of file qmetaobject.h.
Enumerator | |
---|---|
Compatibility | |
Cloned | |
Scriptable |
Definition at line 70 of file qmetaobject.h.
Enumerator | |
---|---|
Method | |
Signal | |
Slot | |
Constructor |
Definition at line 68 of file qmetaobject.h.
|
inline |
Definition at line 59 of file qmetaobject.h.
QMetaMethod::Access QMetaMethod::access | ( | ) | const |
Returns the access specification of this method (private, protected, or public).
Signals are always protected, meaning that you can only emit them from the class or from a subclass.
Definition at line 1496 of file qmetaobject.cpp.
Referenced by QAccessibleObjectPrivate::actionList(), QMetaObjectBuilder::addConstructor(), QMetaObjectBuilder::addMetaObject(), QMetaObjectBuilder::addMethod(), QDeclarativePropertyCache::append(), classIDL(), QDeclarativePropertyCache::create(), findSlot(), generateInterfaceXml(), QScript::hasMethodAccess(), and QTest::isValidSlot().
int QMetaMethod::attributes | ( | ) | const |
Definition at line 1443 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addConstructor(), QMetaObjectBuilder::addMethod(), check_and_warn_compat(), classIDL(), QMetaObject::connectSlotsByName(), findSlot(), generateInterfaceXml(), QScript::QtFunction::mostGeneralMethod(), qax_generateDocumentation(), and QStateMachinePrivate::registerSignalTransition().
|
inline |
Definition at line 75 of file qmetaobject.h.
Referenced by QMetaObject::connectSlotsByName().
bool QMetaMethod::invoke | ( | QObject * | object, |
Qt::ConnectionType | connectionType, | ||
QGenericReturnArgument | returnValue, | ||
QGenericArgument | val0 = QGenericArgument(0) , |
||
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 |
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.
The invocation can be either synchronous or asynchronous, depending on the connectionType:
If connectionType is Qt::DirectConnection, the member will be invoked immediately.
If connectionType is Qt::QueuedConnection, a QEvent will be posted and the member is invoked as soon as the application enters the main event loop.
The return value of this method call is placed in returnValue. If the invocation is asynchronous, the return value cannot be evaluated. You can pass up to ten arguments (val0, val1, val2, val3, val4, val5, val6, val7, val8, and val9) to this method call.
QGenericArgument and QGenericReturnArgument are internal helper classes. Because signals and slots can be dynamically invoked, you must enclose the arguments using the Q_ARG() and Q_RETURN_ARG() macros. Q_ARG() takes a type name and a const reference of that type; Q_RETURN_ARG() takes a type name and a non-const reference.
To asynchronously invoke the animateClick() slot on a QPushButton:
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().
To synchronously invoke the compute(QString, int, double)
slot on some arbitrary object obj
retrieve its return value:
QMetaObject::normalizedSignature() is used here to ensure that the format of the signature is what invoke() expects. E.g. extra whitespace is removed.
If the "compute" slot does not take exactly one QString, one int and one double in the specified order, the call will fail.
Definition at line 1583 of file qmetaobject.cpp.
Referenced by QGraphicsScene::addItem(), QMetaObject::invokeMethod(), QTest::invokeMethod(), QDeclarativeKeysAttached::keyPressed(), and QGraphicsScenePrivate::markDirty().
|
inline |
Definition at line 90 of file qmetaobject.h.
|
inline |
Definition at line 106 of file qmetaobject.h.
|
inline |
Definition at line 122 of file qmetaobject.h.
int QMetaMethod::methodIndex | ( | ) | const |
Returns this method's index.
Definition at line 1458 of file qmetaobject.cpp.
Referenced by QDeclarativeBoundSignal::disconnect(), QDeclarativeBoundSignal::index(), QDeclarativeBoundSignal::init(), and QDeclarativePropertyCache::Data::load().
QMetaMethod::MethodType QMetaMethod::methodType | ( | ) | const |
Returns the type of this method (signal, slot, or method).
Definition at line 1508 of file qmetaobject.cpp.
Referenced by QAccessibleObjectPrivate::actionList(), QMetaObjectBuilder::addConstructor(), QMetaObjectBuilder::addMetaObject(), QMetaObjectBuilder::addMethod(), QDeclarativePropertyCache::append(), check_and_warn_compat(), classIDL(), QObject::connect(), QMetaObject::connectSlotsByName(), QObject::disconnect(), QAxBase::dynamicCallHelper(), findSlot(), QScript::functionConnect(), QScript::functionDisconnect(), generateInterfaceXml(), QScript::hasMethodAccess(), QAxServerBase::internalConnect(), QAxBase::internalInvoke(), QAxServerBase::Invoke(), QAxEventSink::Invoke(), QTest::isValidSlot(), QDeclarativePropertyCache::Data::load(), QMetaObjectPrivate::memberIndexes(), QDBusInterfacePrivate::metacall(), QDeclarativeProxyMetaObject::metaCall(), qax_generateDocumentation(), QAxServerBase::qt_metacall(), and QDBusAbstractAdaptor::setAutoRelaySignals().
QList< QByteArray > QMetaMethod::parameterNames | ( | ) | const |
Returns a list of parameter names.
Definition at line 1367 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addConstructor(), QMetaObjectBuilder::addMethod(), classIDL(), generateInterfaceXml(), qax_generateDocumentation(), QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters(), QScriptContextInfoPrivate::QScriptContextInfoPrivate(), and QDeclarativeEngineDebugService::setMethodBody().
QList< QByteArray > QMetaMethod::parameterTypes | ( | ) | const |
Returns a list of parameter types.
Definition at line 1339 of file qmetaobject.cpp.
Referenced by QDeclarativeObjectMethodScriptClass::callOverloaded(), QDeclarativeObjectMethodScriptClass::callPrecise(), QScript::callQtMethod(), classIDL(), QObject::connect(), QScript::QObjectConnectionManager::execute(), QStateMachinePrivate::handleTransitionSignal(), QSignalSpy::initArgs(), QTest::isValidSlot(), QDeclarativePropertyCache::Data::load(), qax_generateDocumentation(), qDBusParametersForMethod(), QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters(), QTest::qSignalDumperCallback(), QDeclarativeBoundSignal::qt_metacall(), and queued_activate().
int QMetaMethod::revision | ( | ) | const |
Returns the method revision if one was specified by Q_REVISION, otherwise returns 0.
Definition at line 1474 of file qmetaobject.cpp.
Referenced by QDeclarativeTypePrivate::init(), and QDeclarativePropertyCache::Data::load().
const char * QMetaMethod::signature | ( | ) | const |
Returns the signature of this method (e.g., setValue(double)
).
Definition at line 1327 of file qmetaobject.cpp.
Referenced by QAccessibleObjectPrivate::actionList(), QMetaObjectBuilder::addConstructor(), QMetaObjectBuilder::addMethod(), QMetaObjectBuilder::addProperty(), QScript::QObjectConnectionManager::addSignalHandler(), QDeclarativePropertyCache::append(), QDeclarativeObjectMethodScriptClass::callOverloaded(), QScript::callQtMethod(), QDBusAbstractInterface::callWithArgumentList(), check_and_warn_compat(), classIDL(), QDeclarativeObjectMethodScriptClass::connect(), QObject::connect(), QDeclarativeProperty::connectNotifySignal(), ShaderEffectItem::connectPropertySignals(), QMetaObject::connectSlotsByName(), QDeclarativePropertyCache::create(), QDeclarativeObjectMethodScriptClass::disconnect(), QObject::disconnect(), QObject::dumpObjectInfo(), QAxBase::dynamicCallHelper(), QScript::QObjectConnectionManager::execute(), QDeclarativePropertyPrivate::findSignalByName(), findSlot(), for(), QScript::functionConnect(), QScript::functionDisconnect(), generateInterfaceXml(), QScript::QObjectDelegate::getOwnPropertyNames(), QStateMachinePrivate::handleTransitionSignal(), QDeclarativePropertyPrivate::initProperty(), QAxBase::internalInvoke(), QAxServerBase::Invoke(), QAxEventSink::Invoke(), QTest::isValidSlot(), QTest::memberName(), QScript::methodNameEquals(), QScript::methodNameLength(), QDeclarativePropertyCache::Data::name(), QScript::QtFunction::overloadedIndexes(), qax_generateDocumentation(), QMetaMethod_name(), QTest::qPrintDataTags(), QTest::qPrintTestSlots(), QTest::qSignalDumperCallback(), QTest::qSignalDumperCallbackSlot(), QDeclarativeBoundSignal::qt_metacall(), QAxServerBase::qt_metacall(), QDBusAdaptorConnector::relay(), QScript::QObjectConnectionManager::removeSignalHandler(), QDBusAbstractAdaptor::setAutoRelaySignals(), setupDBusInterface(), and QObjectPrivate::signalSignature().
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:
and the information can be accessed by using:
For the moment, moc
doesn't support any special tags.
Definition at line 1434 of file qmetaobject.cpp.
Referenced by QAccessibleObjectPrivate::actionList(), QMetaObjectBuilder::addConstructor(), QMetaObjectBuilder::addMethod(), QDBusAbstractInterface::callWithArgumentList(), findSlot(), and generateInterfaceXml().
const char * QMetaMethod::typeName | ( | ) | const |
Returns the return type of this method, or an empty string if the return type is void.
Definition at line 1397 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addConstructor(), QMetaObjectBuilder::addMethod(), QScript::callQtMethod(), classIDL(), QAxBase::dynamicCallHelper(), findSlot(), generateInterfaceXml(), QAxBase::internalInvoke(), QTest::isValidSlot(), QDeclarativePropertyCache::Data::load(), QDBusInterfacePrivate::metacall(), qax_generateDocumentation(), and QAxServerBase::qt_metacall().
|
friend |
Definition at line 141 of file qmetaobject.h.
|
friend |
Definition at line 142 of file qmetaobject.h.
Definition at line 143 of file qmetaobject.h.
|
private |
Definition at line 140 of file qmetaobject.h.
Referenced by QMetaObject::constructor(), QMetaObjectPrivate::memberIndexes(), and QMetaObject::method().
|
private |
Definition at line 139 of file qmetaobject.h.
Referenced by QMetaObject::constructor(), QObject::disconnect(), QMetaObjectPrivate::memberIndexes(), and QMetaObject::method().