CopperSpice API
1.9.2
|
The QMetaMethod class provides meta data for a given method. More...
Public Types | |
enum | Access |
enum | MethodType |
Public Methods | |
Access | access () const |
const QMetaObject * | getMetaObject () const |
template<class R , class... Ts> | |
bool | invoke (QObject *object, CSReturnArgument< R > retval, Ts &&...Vs) const |
template<class R , class... Ts> | |
bool | invoke (QObject *object, Qt::ConnectionType type, CSReturnArgument< R > retval, Ts &&...Vs) const |
template<class... Ts> | |
bool | invoke (QObject *object, Qt::ConnectionType type, Ts &&...Vs) const |
template<class... Ts> | |
bool | invoke (QObject *object, Ts &&...Vs) const |
bool | isValid () const |
int | methodIndex () const |
const QString & | methodSignature () const |
MethodType | methodType () const |
const QString | name () const |
int | parameterCount () const |
QList< QString > | parameterNames () const |
uint | parameterType (int index) const |
QList< QString > | parameterTypes () const |
int | revision () const |
const QString & | tag () const |
const QString & | typeName () const |
Static Public Methods | |
template<typename SignalClass , typename... SignalArgs> | |
static QMetaMethod | fromSignal (void (SignalClass::*signalMethod)(SignalArgs...)) |
Friends | |
bool | operator!= (const QMetaMethod &method1, const QMetaMethod &method2) |
bool | operator== (const QMetaMethod &method1, const QMetaMethod &method2) |
The QMetaMethod class provides meta data about a particular method in a given class. The meta data consists of various attributes like the method type, return type, full signature, and the parameter names and types. The methods for this class are used only to retrieve the meta information, like methodType() and methodSignature().
Once you have the QMetaObject for a given class, you can retrieve the QMetaMethod object for any registered method in that class.
The QMetaMethod::invoke() method is used to call the method denoted in the QMetaMethod object. This may be useful when designing a plugin based system and the methods may not be known at compile time.
A method is only registered with the meta object system if it is a signal, slot, or declared with the CS_INVOKABLE() macro. Constructors can also be registered with CS_INVOKABLE().
enum QMetaMethod::Access |
This enum describes the access levels for QMetaMethod.
Constant | Value |
---|---|
QMetaMethod::Private | 0 |
QMetaMethod::Protected | 1 |
QMetaMethod::Public | 2 |
This enum describes the method types for QMetaMethod.
Constant | Value | Description |
---|---|---|
QMetaMethod::Method | 0 | Method is a not a signal, slot, or constructor |
QMetaMethod::Signal | 1 | Method is a signal |
QMetaMethod::Slot | 2 | Method is a slot |
QMetaMethod::Constructor | 3 | Method is a constructor |
Access QMetaMethod::access | ( | ) | const |
Returns the access specification of this QMetaMethod object, which is private, protected, or public.
|
static |
Returns either the meta method that corresponds to the given signalMethod or an invalid QMetaMethod if signalMethod is not a signal of the class.
const QMetaObject * QMetaMethod::getMetaObject | ( | ) | const |
Returns the QMetaObject for the current QMetaMethod.
bool QMetaMethod::invoke | ( | QObject * | object, |
CSReturnArgument< R > | retval, | ||
Ts &&... | Vs | ||
) | const |
This overload always invokes this QMetaMethod object using the connection type Qt::AutoConnection.
bool QMetaMethod::invoke | ( | QObject * | object, |
Qt::ConnectionType | type, | ||
CSReturnArgument< R > | retval, | ||
Ts &&... | Vs | ||
) | const |
Invokes this QMetaMethod on the given object. Returns true if the call was possible, returns false if this QMetaMethod is empty, invalid, or the parameters in Vs do not match. The call can be either synchronous or asynchronous, and will depend on the enum value for type.
The Qt::ConnectionType can be one of the following enum values.
The return value for this QMetaMethod object is placed in retval. If the call is queued the return value can not be evaluated and you must enclose the return value in a Q_RETURN_ARG() macro. This macro takes a type name and a non-const reference.
The following is an example to asynchronously invoke the animateClick() slot on a QPushButton.
The following is an example to synchronously invoke the compute(QString, int, double)
slot on obj and retrieve its return value. QMetaObject::normalizedSignature() is used to ensure the format of the signature is what invoke() expects.
bool QMetaMethod::invoke | ( | QObject * | object, |
Qt::ConnectionType | type, | ||
Ts &&... | Vs | ||
) | const |
This overload ignores the return value when this QMetaMethod object is called.
bool QMetaMethod::invoke | ( | QObject * | object, |
Ts &&... | Vs | ||
) | const |
This overload invokes this QMetaMethod object using the connection type Qt::AutoConnection and ignores the return value.
bool QMetaMethod::isValid | ( | ) | const |
Returns true if this QMetaMethod is valid and has a meta object, otherwise returns false.
int QMetaMethod::methodIndex | ( | ) | const |
Returns an index value for this QMetaMethod object.
const QString & QMetaMethod::methodSignature | ( | ) | const |
Returns the signature of this QMetaMethod object.
MethodType QMetaMethod::methodType | ( | ) | const |
Returns the type of this QMetaMethod object which is either signal, slot, or method.
const QString QMetaMethod::name | ( | ) | const |
Returns the name contained in this QMetaMethod object.
int QMetaMethod::parameterCount | ( | ) | const |
Returns the number of parameters in this QMetaMethod object.
Returns a list of parameter names for this QMetaMethod object.
uint QMetaMethod::parameterType | ( | int | index | ) | const |
The value for index represents which parameter in this QMetaMethod object is being queried. This method returns the data type of the indexed parameter based on the enum in QVariant.
For example, if the data type for the parameter is a bool then the value QVariant::Bool is returned. If no valid type is found QVariant::Invalid will be returned.
Returns a list of parameter types for this QMetaMethod object.
int QMetaMethod::revision | ( | ) | const |
Returns this QMetaMethod object revision number if one was specified by Q_REVISION, otherwise returns 0.
const QString & QMetaMethod::tag | ( | ) | const |
Returns the tag associated with this QMetaMethod object. Tags are special macros which make it possible to add extra information about a method. Tag information can be passed as shown in the following example.
and the information can be accessed by using:
const QString & QMetaMethod::typeName | ( | ) | const |
Returns the return data type of this QMetaMethod object.
|
friend |
Returns true if method1 is not equal to method2, otherwise returns false.
|
friend |
Returns true if method1 is equal to method2, otherwise returns false.