The PySide.QtCore.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 PySide.QtCore.QMetaObject instance is created for each PySide.QtCore.QObject subclass that is used in an application, and this instance stores all the meta-information for the PySide.QtCore.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:
- PySide.QtCore.QMetaObject.className() returns the name of a class.
- PySide.QtCore.QMetaObject.superClass() returns the superclass’s meta-object.
- PySide.QtCore.QMetaObject.method() and PySide.QtCore.QMetaObject.methodCount() provide information about a class’s meta-methods (signals, slots and other invokable member functions).
- PySide.QtCore.QMetaObject.enumerator() and PySide.QtCore.QMetaObject.enumeratorCount() and provide information about a class’s enumerators.
- PySide.QtCore.QMetaObject.propertyCount() and PySide.QtCore.QMetaObject.property() provide information about a class’s properties.
- PySide.QtCore.QMetaObject.constructor() and PySide.QtCore.QMetaObject.constructorCount() provide information about a class’s meta-constructors.
The index functions PySide.QtCore.QMetaObject.indexOfConstructor() , PySide.QtCore.QMetaObject.indexOfMethod() , PySide.QtCore.QMetaObject.indexOfEnumerator() , and PySide.QtCore.QMetaObject.indexOfProperty() map names of constructors, member functions, enumerators, or properties to indexes in the meta-object. For example, Qt uses PySide.QtCore.QMetaObject.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 PySide.QtCore.QMetaClassInfo objects. The number of pairs is returned by PySide.QtCore.QMetaObject.classInfoCount() , single pairs are returned by PySide.QtCore.QMetaObject.classInfo() , and you can search for pairs with PySide.QtCore.QMetaObject.indexOfClassInfo() .
See also
PySide.QtCore.QMetaClassInfo PySide.QtCore.QMetaEnum PySide.QtCore.QMetaMethod PySide.QtCore.QMetaProperty QMetaType Meta-Object System
Constant | Description |
---|---|
QMetaObject.InvokeSlot | |
QMetaObject.EmitSignal | |
QMetaObject.ReadProperty | |
QMetaObject.WriteProperty | |
QMetaObject.ResetProperty | |
QMetaObject.QueryPropertyDesignable | |
QMetaObject.QueryPropertyScriptable | |
QMetaObject.QueryPropertyStored | |
QMetaObject.QueryPropertyEditable | |
QMetaObject.QueryPropertyUser | |
QMetaObject.CreateInstance |
Parameters: | obj – PySide.QtCore.QObject |
---|---|
Return type: | PySide.QtCore.QObject |
Returns obj if object obj inherits from this meta-object; otherwise returns 0.
Parameters: |
|
---|---|
Return type: | PySide.QtCore.bool |
Returns true if the signal and method arguments are compatible; otherwise returns false.
Both signal and method are expected to be normalized.
Parameters: | index – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.QMetaClassInfo |
Returns the meta-data for the item of class information with the given index .
Example:
class MyClass:
Q_CLASSINFO("author", "Sabrina Schweinsteiger")
Q_CLASSINFO("url", "http://doc.moosesoft.co.uk/1.0/")
...
Return type: | PySide.QtCore.int |
---|
Returns the number of items of class information in this class.
Return type: | PySide.QtCore.int |
---|
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.
Return type: | str |
---|
Returns the class name.
Parameters: | o – PySide.QtCore.QObject |
---|
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:
def on_<object name>_<signal name>(<signal parameters>)
Let’s assume our object has a child object of type PySide.QtGui.QPushButton with the object name button1 . The slot to catch the button’s clicked() signal would be:
def on_button1_clicked()
See also
Parameters: | index – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.QMetaMethod |
Returns the meta-data for the constructor with the given index .
Return type: | PySide.QtCore.int |
---|
Returns the number of constructors in this class.
Parameters: |
|
---|---|
Return type: | PySide.QtCore.bool |
Parameters: | index – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.QMetaEnum |
Returns the meta-data for the enumerator with the given index .
Return type: | PySide.QtCore.int |
---|
Returns the number of enumerators in this class.
Return type: | PySide.QtCore.int |
---|
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.
Parameters: | name – str |
---|---|
Return type: | PySide.QtCore.int |
Finds class information item name and returns its index; otherwise returns -1.
Parameters: | constructor – str |
---|---|
Return type: | PySide.QtCore.int |
Finds constructor and returns its index; otherwise returns -1.
Note that the constructor has to be in normalized form, as returned by PySide.QtCore.QMetaObject.normalizedSignature() .
Parameters: | name – str |
---|---|
Return type: | PySide.QtCore.int |
Finds enumerator name and returns its index; otherwise returns -1.
Parameters: | method – str |
---|---|
Return type: | PySide.QtCore.int |
Finds method and returns its index; otherwise returns -1.
Note that the method has to be in normalized form, as returned by PySide.QtCore.QMetaObject.normalizedSignature() .
Parameters: | name – str |
---|---|
Return type: | PySide.QtCore.int |
Finds property name and returns its index; otherwise returns -1.
Parameters: | signal – str |
---|---|
Return type: | PySide.QtCore.int |
Finds signal and returns its index; otherwise returns -1.
This is the same as PySide.QtCore.QMetaObject.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 PySide.QtCore.QMetaObject.normalizedSignature() .
Parameters: | slot – str |
---|---|
Return type: | PySide.QtCore.int |
Finds slot and returns its index; otherwise returns -1.
This is the same as PySide.QtCore.QMetaObject.indexOfMethod() , except that it will return -1 if the method exists but isn’t a slot.
Parameters: |
|
---|---|
Return type: | PySide.QtCore.bool |
Parameters: |
|
---|---|
Return type: | PySide.QtCore.bool |
Parameters: |
|
---|---|
Return type: | PySide.QtCore.bool |
This function overloads PySide.QtCore.QMetaObject.invokeMethod() .
This overload always invokes the member using the connection type Qt.AutoConnection .
Parameters: |
|
---|---|
Return type: | PySide.QtCore.bool |
This function overloads PySide.QtCore.QMetaObject.invokeMethod() .
This overload invokes the member using the connection type Qt.AutoConnection and ignores return values.
Parameters: | index – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.QMetaMethod |
Returns the meta-data for the method with the given index .
Return type: | PySide.QtCore.int |
---|
Returns the number of methods in this class, including the number of properties provided by each base class. These include signals and slots as well as normal member functions.
Use code like the following to obtain a PySide.QtCore.QStringList containing the methods specific to a given class:
metaObject = obj.metaObject()
methods = [metaObject.method(i).signature() for i in range(metaObject.methodOffset(), metaObject.methodCount())]
Return type: | PySide.QtCore.int |
---|
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 PySide.QtCore.QObject has the deleteLater() slot and a destroyed() signal).
Parameters: |
|
---|---|
Return type: |
Constructs a new instance of this class. You can pass up to ten arguments (val0 , val1 , val2 , val3 , val4 , val5 , val6 , val7 , val8 , and val9 ) to the constructor. Returns the new object, or 0 if no suitable constructor is available.
Note that only constructors that are declared with the Q_INVOKABLE() modifier are made available through the meta-object system.
See also
Parameters: | method – str |
---|---|
Return type: | PySide.QtCore.QByteArray |
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.
Parameters: | type – str |
---|---|
Return type: | PySide.QtCore.QByteArray |
Normalizes a type .
See QMetaObject.normalizedSignature() for a description on how Qt normalizes.
Example:
normType = QMetaObject.normalizedType(" int const *")
# normType is now "const int*"
Parameters: | index – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.QMetaProperty |
Returns the meta-data for the property with the given index . If no such property exists, a null PySide.QtCore.QMetaProperty is returned.
Return type: | PySide.QtCore.int |
---|
Returns the number of properties in this class, including the number of properties provided by each base class.
Use code like the following to obtain a PySide.QtCore.QStringList containing the properties specific to a given class:
metaObject = obj.metaObject()
properties = [metaObject.property(i).name() for i in range(metaObject.propertyOffset(), metaObject.propertyCount())]
Return type: | PySide.QtCore.int |
---|
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 PySide.QtCore.QObject has the name() property).
Return type: | PySide.QtCore.QMetaObject |
---|
Returns the meta-object of the superclass, or 0 if there is no such object.
Return type: | PySide.QtCore.QMetaProperty |
---|
Returns the property that has the USER flag set to true.
See also