Home · All Classes · Main Classes · Annotated · Grouped Classes · Functions

QMetaObject Class Reference

The QMetaObject class contains meta information about Qt objects. More...

#include <QMetaObject>

Part of the QtCore module.

Public Functions

Static Public Members


Detailed Description

The QMetaObject class contains meta information about Qt objects.

The Qt Meta Object System in Qt is responsible for the signals and slots inter-object communication mechanism, runtime type information, and the Qt property system. A single QMetaObject instance is created for each QObject subclass that is used in an application, and this instance stores all the meta information for the QObject subclass.

This class is not normally required for application programming, but it is useful if you write meta applications, such as scripting engines or GUI builders.

The functions you are most likely to find useful are these:

The index functions indexOfMember(), indexOfEnumerator(), and indexOfProperty() map names of member functions, enumerators, or properties to indexes in the meta object. For example, Qt uses indexOfMember() internally when you connect a signal to a slot.

Classes can also have a list of name--value pairs of additional class information. The number of pairs is returned by classInfoCount(), single pairs are returned by classInfo(), and you can search for pairs with indexOfClassInfo().

See also moc (Meta QObject Compiler).


Member Function Documentation

bool QMetaObject::checkConnectArgs ( const char * signal, const char * member )   [static]

Returns true if the signal and member arguments are compatible; otherwise returns false.

Both signal and member are expected to be normalized.

See also normalizedSignature().

QMetaClassInfo QMetaObject::classInfo ( int index ) const

Returns the meta data for the item of class information with the given index.

See also indexOfClassInfo().

int QMetaObject::classInfoCount () const

Returns the number of items of class information in this class.

int QMetaObject::classInfoOffset () const

Returns the class information offset for this class; i.e. the index position of this class's first class information item. If the class has no super-classes with class information, the offset is 0; otherwise the offset is the sum of all the class information items in the class's super-classes.

const char * QMetaObject::className () const

Returns the class name.

See also superClass().

QMetaEnum QMetaObject::enumerator ( int index ) const

Returns the meta data for the enumerator with the given index.

See also indexOfEnumerator().

int QMetaObject::enumeratorCount () const

Returns the number of enumerators in this class.

See also enumerator().

int QMetaObject::enumeratorOffset () const

Returns the enumerator offset for this class; i.e. the index position of this class's first enumerator. If the class has no super-classes with enumerators, the offset is 0; otherwise the offset is the sum of all the enumerators in the class's super-classes.

int QMetaObject::indexOfClassInfo ( const char * name ) const

Finds class information item name and returns its index; otherwise returns -1.

See also classInfo() and classInfoCount().

int QMetaObject::indexOfEnumerator ( const char * name ) const

Finds enumerator name and returns its index; otherwise returns -1.

See also enumerator() and enumeratorCount().

int QMetaObject::indexOfMember ( const char * member ) const

Finds member and returns its index; otherwise returns -1.

See also member() and memberCount().

int QMetaObject::indexOfProperty ( const char * name ) const

Finds property name and returns its index; otherwise returns -1.

See also property() and propertyCount().

int QMetaObject::indexOfSignal ( const char * signal ) const

Finds signal and returns its index; otherwise returns -1.

See also indexOfMember(), member(), and memberCount().

int QMetaObject::indexOfSlot ( const char * slot ) const

Finds slot and returns its index; otherwise returns -1.

See also indexOfMember(), member(), and memberCount().

bool QMetaObject::invokeMember ( QObject * obj, const char * member, Qt::ConnectionType type, QGenericReturnArgument ret, 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() )   [static]

Invokes the member (a signal or a slot name) on the object obj. 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 type:

The return value of the member function call is placed in ret. 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 the member function.

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:

    QMetaObject::invokeMember(pushButton, "animateClick",
                              Qt::QueuedConnection);

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

    QString retVal;
    QMetaObject::invokeMember(obj, "compute", Qt::DirectConnection,
                              Q_RETURN_ARG(QString, retVal),
                              Q_ARG(QString, "sqrt"),
                              Q_ARG(int, 42),
                              Q_ARG(double, 9.7));

If the "compute" slot does not take exactly one QString, one int and one double in the specified order, the call will fail.

bool QMetaObject::invokeMember ( QObject * obj, const char * member, 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() )   [static]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

bool QMetaObject::invokeMember ( QObject * obj, const char * member, QGenericReturnArgument ret, 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() )   [static]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

This overload always invokes the member using the connection type Qt::AutoConnection.

bool QMetaObject::invokeMember ( QObject * obj, const char * member, Qt::ConnectionType type, 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() )   [static]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

This overload can be used if the return value of the member is of no interest.

QMetaMember QMetaObject::member ( int index ) const

Returns the meta data for the member with the given index.

int QMetaObject::memberCount () const

Returns the number of slots in this class.

See also slot().

int QMetaObject::memberOffset () const

Returns the member offset for this class; i.e. the index position of this class's first member. The offset is the sum of all the members in the class's super-classes (which is always positive since QObject has the deleteLater() slot and a destroyed() signal).

QByteArray QMetaObject::normalizedSignature ( const char * member )   [static]

Normalizes the signature of the given member.

Qt uses normalized signatures to decide whether two given signals and slots are compatible. Normalization reduces whitespace to a minimum, moves 'const' to the front where appropriate, removes 'const' from value types and replaces const references with values.

See also checkConnectArgs().

QMetaProperty QMetaObject::property ( int index ) const

Returns the meta data for the property with the given index.

See also indexOfProperty().

int QMetaObject::propertyCount () const

Returns the number of properties in this class.

See also property().

int QMetaObject::propertyOffset () const

Returns the property offset for this class; i.e. the index position of this class's first property. The offset is the sum of all the properties in the class's super-classes (which is always positive since QObject has the name() property).

const QMetaObject * QMetaObject::superClass () const

Returns the meta object of the super-class, or 0 if there is no such object.


Copyright © 2005 Trolltech Trademarks
Qt 4.0.0-b2