|  | Home · All Classes · Modules

# QMetaObject Class Reference
[QtCore module]

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

### Methods

- __init__ (self)
- __init__ (self, QMetaObject other)
- QMetaClassInfo classInfo (self, int index)
- int classInfoCount (self)
- int classInfoOffset (self)
- str className (self)
- QMetaEnum enumerator (self, int index)
- int enumeratorCount (self)
- int enumeratorOffset (self)
- int indexOfClassInfo (self, str name)
- int indexOfEnumerator (self, str name)
- int indexOfMethod (self, str method)
- int indexOfProperty (self, str name)
- int indexOfSignal (self, str signal)
- int indexOfSlot (self, str slot)
- QMetaMethod method (self, int index)
- int methodCount (self)
- int methodOffset (self)
- QMetaProperty property (self, int index)
- int propertyCount (self)
- int propertyOffset (self)
- QMetaObject superClass (self)
- QMetaProperty userProperty (self)

### Static Methods

- bool checkConnectArgs (str signal, str method)
- connectSlotsByName (QObject o)
- QByteArray normalizedSignature (str method)
- QByteArray normalizedType (str type)

## 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 object is available as QObject.metaObject().

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:

- className() returns the name of a class.
- superClass() returns the superclass's meta-object.
- method() and methodCount() provide information about a class's meta-methods (signals, slots and other member functions).
- enumerator() and enumeratorCount() and provide information about a class's enumerators.
- propertyCount() and property() provide information about a class's properties.

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

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

See also QMetaClassInfo, QMetaEnum, QMetaMethod, QMetaProperty, QMetaType, and Meta-Object System.

## Method Documentation

### QMetaObject.__init__ (self)

### QMetaObject.__init__ (self, QMetaObject other)

### bool QMetaObject.checkConnectArgs (str signal, str method)

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

Both signal and method are expected to be normalized.

See also normalizedSignature().

### QMetaClassInfo QMetaObject.classInfo (self, int index)

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

Example:

     class MyClass
     {
         Q_OBJECT
         Q_CLASSINFO("author", "Sabrina Schweinsteiger")
         Q_CLASSINFO("url", "http://doc.moosesoft.co.uk/1.0/")

     public:
         ...
     };

See also classInfoCount(), classInfoOffset(), and indexOfClassInfo().

### int QMetaObject.classInfoCount (self)

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

See also classInfo(), classInfoOffset(), and indexOfClassInfo().

### int QMetaObject.classInfoOffset (self)

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 superclasses with class information, the offset is 0; otherwise the offset is the sum of all the class information items in the class's superclasses.

See also classInfo(), classInfoCount(), and indexOfClassInfo().

### str QMetaObject.className (self)

Returns the class name.

See also superClass().

### QMetaObject.connectSlotsByName (QObject o)

Searches recursively for all child objects of the given object, and connects matching signals from them to slots of object that follow the following form:

     void on_<widget name>_<signal name>(<signal parameters>);

Let's assume our object has a child object of type QPushButton with the object name `button1`. The slot to catch the button's `clicked()` signal would be:

     void on_button1_clicked();

See also QObject.setObjectName().

### QMetaEnum QMetaObject.enumerator (self, int index)

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

See also enumeratorCount(), enumeratorOffset(), and indexOfEnumerator().

### int QMetaObject.enumeratorCount (self)

Returns the number of enumerators in this class.

See also enumerator(), enumeratorOffset(), and indexOfEnumerator().

### int QMetaObject.enumeratorOffset (self)

Returns the enumerator offset for this class; i.e. the index position of this class's first enumerator.

If the class has no superclasses with enumerators, the offset is 0; otherwise the offset is the sum of all the enumerators in the class's superclasses.

See also enumerator(), enumeratorCount(), and indexOfEnumerator().

### int QMetaObject.indexOfClassInfo (self, str name)

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

See also classInfo(), classInfoCount(), and classInfoOffset().

### int QMetaObject.indexOfEnumerator (self, str name)

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

See also enumerator(), enumeratorCount(), and enumeratorOffset().

### int QMetaObject.indexOfMethod (self, str method)

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

Note that the method has to be in normalized form, as returned by normalizedSignature().

See also method(), methodCount(), methodOffset(), and normalizedSignature().

### int QMetaObject.indexOfProperty (self, str name)

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

See also property(), propertyCount(), and propertyOffset().

### int QMetaObject.indexOfSignal (self, str signal)

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

This is the same as indexOfMethod(), except that it will return -1 if the method exists but isn't a signal.

Note that the signal has to be in normalized form, as returned by normalizedSignature().

See also indexOfMethod(), normalizedSignature(), method(), methodCount(), and methodOffset().

### int QMetaObject.indexOfSlot (self, str slot)

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

This is the same as indexOfMethod(), except that it will return -1 if the method exists but isn't a slot.

See also indexOfMethod(), method(), methodCount(), and methodOffset().

### QMetaMethod QMetaObject.method (self, int index)

Returns the meta-data for the method with the given index.

See also methodCount(), methodOffset(), and indexOfMethod().

### int QMetaObject.methodCount (self)

Returns the number of methods in this class. These include ordinary methods, signals, and slots.

See also method(), methodOffset(), and indexOfMethod().

### int QMetaObject.methodOffset (self)

Returns the method offset for this class; i.e. the index position of this class's first member function.

The offset is the sum of all the methods in the class's superclasses (which is always positive since QObject has the deleteLater() slot and a destroyed() signal).

See also method(), methodCount(), and indexOfMethod().

### QByteArray QMetaObject.normalizedSignature (str method)

Normalizes the signature of the given method.

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() and normalizedType().

### QByteArray QMetaObject.normalizedType (str type)

Normalizes a type.

See QMetaObject.normalizedSignature() for a description on how Qt normalizes.

Example:

     QByteArray normType = QMetaObject.normalizedType(" int    const  *");
     // normType is now "const int*"

This function was introduced in Qt 4.2.

See also normalizedSignature().

### QMetaProperty QMetaObject.property (self, int index)

Returns the meta-data for the property with the given index. If no such property exists, a null QMetaProperty is returned.

See also propertyCount(), propertyOffset(), and indexOfProperty().

### int QMetaObject.propertyCount (self)

Returns the number of properties in this class.

See also property(), propertyOffset(), and indexOfProperty().

### int QMetaObject.propertyOffset (self)

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 superclasses (which is always positive since QObject has the name() property).

See also property(), propertyCount(), and indexOfProperty().

### QMetaObject QMetaObject.superClass (self)

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

See also className().

### QMetaProperty QMetaObject.userProperty (self)

Returns the property that has the `USER` flag set to true.

This function was introduced in Qt 4.2.

See also QMetaProperty.isUser().