PySide.QtCore.QMetaObject class contains meta-information about Qt objects.
Qt 元对象系统 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:
The index functions PySide.QtCore.QMetaObject.indexOfConstructor() , PySide.QtCore.QMetaObject.indexOfMethod() , PySide.QtCore.QMetaObject.indexOfEnumerator() ,和 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() .
| 常量 | 描述 |
|---|---|
| QMetaObject.InvokeSlot | |
| QMetaObject.EmitSignal | |
| QMetaObject.ReadProperty | |
| QMetaObject.WriteProperty | |
| QMetaObject.ResetProperty | |
| QMetaObject.QueryPropertyDesignable | |
| QMetaObject.QueryPropertyScriptable | |
| QMetaObject.QueryPropertyStored | |
| QMetaObject.QueryPropertyEditable | |
| QMetaObject.QueryPropertyUser | |
| QMetaObject.CreateInstance |
| 参数: | obj – PySide.QtCore.QObject |
|---|---|
| 返回类型: | PySide.QtCore.QObject |
返回 obj if object obj inherits from this meta-object; otherwise returns 0.
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.bool |
返回 true 若 signal and 方法 arguments are compatible; otherwise returns false.
Both signal and 方法 are expected to be normalized.
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.QMetaClassInfo |
返回用于类信息项的元数据,采用给定 index .
范例:
class MyClass:
Q_CLASSINFO("author", "Sabrina Schweinsteiger")
Q_CLASSINFO("url", "http://doc.moosesoft.co.uk/1.0/")
...
| 返回类型: | PySide.QtCore.int |
|---|
返回此类类信息的项数。
| 返回类型: | 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.
| 返回类型: | str |
|---|
Returns the class name.
| 参数: | 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 采用 object name button1 . The slot to catch the button's clicked() signal would be:
def on_button1_clicked()
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.QMetaMethod |
Returns the meta-data for the constructor with the given index .
| 返回类型: | PySide.QtCore.int |
|---|
返回此类中的构造函数数。
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.bool |
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.QMetaEnum |
Returns the meta-data for the enumerator with the given index .
| 返回类型: | PySide.QtCore.int |
|---|
Returns the number of enumerators in this class.
| 返回类型: | 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.
| 参数: | name – str |
|---|---|
| 返回类型: | PySide.QtCore.int |
Finds class information item name and returns its index; otherwise returns -1.
| 参数: | 构造函数 – str |
|---|---|
| 返回类型: | PySide.QtCore.int |
查找 构造函数 and returns its index; otherwise returns -1.
注意: 构造函数 has to be in normalized form, as returned by PySide.QtCore.QMetaObject.normalizedSignature() .
| 参数: | name – str |
|---|---|
| 返回类型: | PySide.QtCore.int |
Finds enumerator name and returns its index; otherwise returns -1.
| 参数: | 方法 – str |
|---|---|
| 返回类型: | PySide.QtCore.int |
查找 方法 and returns its index; otherwise returns -1.
注意: 方法 has to be in normalized form, as returned by PySide.QtCore.QMetaObject.normalizedSignature() .
| 参数: | name – str |
|---|---|
| 返回类型: | PySide.QtCore.int |
Finds property name and returns its index; otherwise returns -1.
| 参数: | signal – str |
|---|---|
| 返回类型: | PySide.QtCore.int |
查找 signal and returns its index; otherwise returns -1.
这如同 PySide.QtCore.QMetaObject.indexOfMethod() , except that it will return -1 if the method exists but isn't a signal.
注意: signal has to be in normalized form, as returned by PySide.QtCore.QMetaObject.normalizedSignature() .
| 参数: | slot – str |
|---|---|
| 返回类型: | PySide.QtCore.int |
查找 slot and returns its index; otherwise returns -1.
这如同 PySide.QtCore.QMetaObject.indexOfMethod() , except that it will return -1 if the method exists but isn't a slot.
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.bool |
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.bool |
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.bool |
此函数重载 PySide.QtCore.QMetaObject.invokeMethod() .
This overload always invokes the member using the connection type Qt.AutoConnection .
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.bool |
此函数重载 PySide.QtCore.QMetaObject.invokeMethod() .
This overload invokes the member using the connection type Qt.AutoConnection and ignores return values.
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.QMetaMethod |
Returns the meta-data for the method with the given index .
| 返回类型: | PySide.QtCore.int |
|---|
Returns the number of methods known to the meta-object system in this class, including the number of properties provided by each base class. These include signals and slots as well as member functions declared with the Q_INVOKABLE() 宏。
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())]
| 返回类型: | 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).
| 参数: |
|
|---|---|
| 返回类型: |
Constructs a new instance of this class. You can pass up to ten arguments ( val0 , val1 , val2 , val3 , val4 , val5 , val6 , val7 , val8 ,和 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.
另请参阅
| 参数: | 方法 – str |
|---|---|
| 返回类型: | PySide.QtCore.QByteArray |
Normalizes the signature of the given 方法 .
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.
| 参数: | type – str |
|---|---|
| 返回类型: | PySide.QtCore.QByteArray |
Normalizes a type .
见 QMetaObject.normalizedSignature() for a description on how Qt normalizes.
范例:
normType = QMetaObject.normalizedType(" int const *")
# normType is now "const int*"
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.QMetaProperty |
Returns the meta-data for the property with the given index . If no such property exists, a null PySide.QtCore.QMetaProperty 被返回。
| 返回类型: | 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())]
| 返回类型: | 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 拥有 name() 特性)。
| 返回类型: | PySide.QtCore.QMetaObject |
|---|
Returns the meta-object of the superclass, or 0 if there is no such object.
| 返回类型: | PySide.QtCore.QMetaProperty |
|---|
Returns the property that has the USER flag set to true.