• PySide 模块
  • PySide.QtCore
  • 内容表

    上一话题

    QMetaMethod

    下一话题

    QGenericReturnArgument

    QMetaObject

    概要

    函数

    静态函数

    • def checkConnectArgs (signal, method)
    • def connectSlotsByName (o)
    • def disconnect (sender, signal_index, receiver, method_index)
    • def invokeMethod (obj, member, arg__3, ret[, val0=QGenericArgument(0)[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]]])
    • def invokeMethod (obj, member, ret[, val0=QGenericArgument(0)[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]]])
    • def invokeMethod (obj, member, type[, val0=QGenericArgument(0)[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]]])
    • def invokeMethod (obj, member[, val0=QGenericArgument(0)[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]]])
    • def normalizedSignature (method)
    • def normalizedType (type)

    详细描述

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

    class PySide.QtCore. QMetaObject
    PySide.QtCore.QMetaObject. 调用
    常量 描述
    QMetaObject.InvokeSlot  
    QMetaObject.EmitSignal  
    QMetaObject.ReadProperty  
    QMetaObject.WriteProperty  
    QMetaObject.ResetProperty  
    QMetaObject.QueryPropertyDesignable  
    QMetaObject.QueryPropertyScriptable  
    QMetaObject.QueryPropertyStored  
    QMetaObject.QueryPropertyEditable  
    QMetaObject.QueryPropertyUser  
    QMetaObject.CreateInstance  
    PySide.QtCore.QMetaObject. cast ( obj )
    参数: obj PySide.QtCore.QObject
    返回类型: PySide.QtCore.QObject

    返回 obj if object obj inherits from this meta-object; otherwise returns 0.

    static PySide.QtCore.QMetaObject. checkConnectArgs ( signal , 方法 )
    参数:
    • signal – str
    • 方法 – str
    返回类型:

    PySide.QtCore.bool

    返回 true 若 signal and 方法 arguments are compatible; otherwise returns false.

    Both signal and 方法 are expected to be normalized.

    PySide.QtCore.QMetaObject. classInfo ( index )
    参数: 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.QMetaObject. classInfoCount ( )
    返回类型: PySide.QtCore.int

    返回此类类信息的项数。

    PySide.QtCore.QMetaObject. classInfoOffset ( )
    返回类型: 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.

    PySide.QtCore.QMetaObject. className ( )
    返回类型: str

    Returns the class name.

    static PySide.QtCore.QMetaObject. connectSlotsByName ( o )
    参数: 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()
    										
    PySide.QtCore.QMetaObject. 构造函数 ( index )
    参数: index PySide.QtCore.int
    返回类型: PySide.QtCore.QMetaMethod

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

    PySide.QtCore.QMetaObject. constructorCount ( )
    返回类型: PySide.QtCore.int

    返回此类中的构造函数数。

    static PySide.QtCore.QMetaObject. disconnect ( sender , signal_index , receiver , method_index )
    参数:
    返回类型:

    PySide.QtCore.bool

    PySide.QtCore.QMetaObject. enumerator ( index )
    参数: index PySide.QtCore.int
    返回类型: PySide.QtCore.QMetaEnum

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

    PySide.QtCore.QMetaObject. enumeratorCount ( )
    返回类型: PySide.QtCore.int

    Returns the number of enumerators in this class.

    PySide.QtCore.QMetaObject. enumeratorOffset ( )
    返回类型: 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.

    PySide.QtCore.QMetaObject. indexOfClassInfo ( name )
    参数: name – str
    返回类型: PySide.QtCore.int

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

    PySide.QtCore.QMetaObject. indexOfConstructor ( 构造函数 )
    参数: 构造函数 – str
    返回类型: PySide.QtCore.int

    查找 构造函数 and returns its index; otherwise returns -1.

    注意: 构造函数 has to be in normalized form, as returned by PySide.QtCore.QMetaObject.normalizedSignature() .

    PySide.QtCore.QMetaObject. indexOfEnumerator ( name )
    参数: name – str
    返回类型: PySide.QtCore.int

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

    PySide.QtCore.QMetaObject. indexOfMethod ( 方法 )
    参数: 方法 – str
    返回类型: PySide.QtCore.int

    查找 方法 and returns its index; otherwise returns -1.

    注意: 方法 has to be in normalized form, as returned by PySide.QtCore.QMetaObject.normalizedSignature() .

    PySide.QtCore.QMetaObject. indexOfProperty ( name )
    参数: name – str
    返回类型: PySide.QtCore.int

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

    PySide.QtCore.QMetaObject. indexOfSignal ( signal )
    参数: 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() .

    PySide.QtCore.QMetaObject. indexOfSlot ( slot )
    参数: 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.

    static PySide.QtCore.QMetaObject. invokeMethod ( obj , member , type [ , val0=QGenericArgument(0) [ , val1=QGenericArgument() [ , val2=QGenericArgument() [ , val3=QGenericArgument() [ , val4=QGenericArgument() [ , val5=QGenericArgument() [ , val6=QGenericArgument() [ , val7=QGenericArgument() [ , val8=QGenericArgument() [ , val9=QGenericArgument() ] ] ] ] ] ] ] ] ] ] )
    参数:
    返回类型:

    PySide.QtCore.bool

    static PySide.QtCore.QMetaObject. invokeMethod ( obj , member , arg__3 , ret [ , val0=QGenericArgument(0) [ , val1=QGenericArgument() [ , val2=QGenericArgument() [ , val3=QGenericArgument() [ , val4=QGenericArgument() [ , val5=QGenericArgument() [ , val6=QGenericArgument() [ , val7=QGenericArgument() [ , val8=QGenericArgument() [ , val9=QGenericArgument() ] ] ] ] ] ] ] ] ] ] )
    参数:
    返回类型:

    PySide.QtCore.bool

    static PySide.QtCore.QMetaObject. invokeMethod ( obj , member , ret [ , val0=QGenericArgument(0) [ , val1=QGenericArgument() [ , val2=QGenericArgument() [ , val3=QGenericArgument() [ , val4=QGenericArgument() [ , val5=QGenericArgument() [ , val6=QGenericArgument() [ , val7=QGenericArgument() [ , val8=QGenericArgument() [ , val9=QGenericArgument() ] ] ] ] ] ] ] ] ] ] )
    参数:
    返回类型:

    PySide.QtCore.bool

    此函数重载 PySide.QtCore.QMetaObject.invokeMethod() .

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

    static PySide.QtCore.QMetaObject. invokeMethod ( obj , member [ , val0=QGenericArgument(0) [ , val1=QGenericArgument() [ , val2=QGenericArgument() [ , val3=QGenericArgument() [ , val4=QGenericArgument() [ , val5=QGenericArgument() [ , val6=QGenericArgument() [ , val7=QGenericArgument() [ , val8=QGenericArgument() [ , val9=QGenericArgument() ] ] ] ] ] ] ] ] ] ] )
    参数:
    返回类型:

    PySide.QtCore.bool

    此函数重载 PySide.QtCore.QMetaObject.invokeMethod() .

    This overload invokes the member using the connection type Qt.AutoConnection and ignores return values.

    PySide.QtCore.QMetaObject. 方法 ( index )
    参数: index PySide.QtCore.int
    返回类型: PySide.QtCore.QMetaMethod

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

    PySide.QtCore.QMetaObject. methodCount ( )
    返回类型: 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.QMetaObject. methodOffset ( )
    返回类型: 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).

    PySide.QtCore.QMetaObject. newInstance ( [ val0=QGenericArgument(0) [ , val1=QGenericArgument() [ , val2=QGenericArgument() [ , val3=QGenericArgument() [ , val4=QGenericArgument() [ , val5=QGenericArgument() [ , val6=QGenericArgument() [ , val7=QGenericArgument() [ , val8=QGenericArgument() [ , val9=QGenericArgument() ] ] ] ] ] ] ] ] ] ] )
    参数:
    返回类型:

    PySide.QtCore.QObject

    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.

    static PySide.QtCore.QMetaObject. normalizedSignature ( 方法 )
    参数: 方法 – 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.

    static PySide.QtCore.QMetaObject. normalizedType ( type )
    参数: 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*"
    											
    PySide.QtCore.QMetaObject. 特性 ( index )
    参数: 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.QMetaObject. propertyCount ( )
    返回类型: 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.QMetaObject. propertyOffset ( )
    返回类型: 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. superClass ( )
    返回类型: PySide.QtCore.QMetaObject

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

    PySide.QtCore.QMetaObject. userProperty ( )
    返回类型: PySide.QtCore.QMetaProperty

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