QMetaProperty Class Reference

[ QtCore module]

The QMetaProperty class provides meta-data about a property. 更多...

方法


详细描述

The QMetaProperty class provides meta-data about a property.

Property meta-data is obtained from an object's meta-object. See QMetaObject.property () 和 QMetaObject.propertyCount () 了解细节。

Property Meta-Data

A property has a name () 和 type (), as well as various attributes that specify its behavior: isReadable (), isWritable (), isDesignable (), isScriptable (),和 isStored ().

If the property is an enumeration, isEnumType () returns true; if the property is an enumeration that is also a flag (i.e. its values can be combined using the OR operator), isEnumType () 和 isFlagType () both return true. The enumerator for these types is available from enumerator ().

The property's values are set and retrieved with read (), write (),和 reset (); they can also be changed through QObject 's set and get functions. 见 QObject.setProperty () and QObject.property () for details.

Copying and Assignment

QMetaProperty objects can be copied by value. However, each copy will refer to the same underlying property meta-data.


方法文档编制

QMetaProperty.__init__ ( self )

QMetaProperty.__init__ ( self , QMetaProperty )

QMetaEnum QMetaProperty.enumerator ( self )

Returns the enumerator if this property's type is an enumerator type; otherwise the returned value is undefined.

另请参阅 isEnumType () 和 isFlagType ().

bool QMetaProperty.hasNotifySignal ( self )

Returns true if this property has a corresponding change notify signal; otherwise returns false.

另请参阅 notifySignal ().

bool QMetaProperty.hasStdCppSet ( self )

bool QMetaProperty.isConstant ( self )

Returns true if the property is constant; otherwise returns false.

A property is constant if the Q_PROPERTY() 's CONSTANT attribute is set.

该函数在 Qt 4.6 引入。

bool QMetaProperty.isDesignable ( self , QObject   object  = None)

Returns true if this property is designable for the given object ;否则返回 false。

若无 object is given, the function returns false if the Q_PROPERTY() 's DESIGNABLE attribute is false; otherwise returns true (if the attribute is true or is a function or expression).

另请参阅 isScriptable () 和 isStored ().

bool QMetaProperty.isEditable ( self , QObject   object  = None)

bool QMetaProperty.isEnumType ( self )

Returns true if the property's type is an enumeration value; otherwise returns false.

另请参阅 enumerator () 和 isFlagType ().

bool QMetaProperty.isFinal ( self )

Returns true if the property is final; otherwise returns false.

A property is final if the Q_PROPERTY() 's FINAL attribute is set.

该函数在 Qt 4.6 引入。

bool QMetaProperty.isFlagType ( self )

Returns true if the property's type is an enumeration value that is used as a flag; otherwise returns false.

Flags can be combined using the OR operator. A flag type is implicitly also an enum type.

另请参阅 isEnumType (), enumerator (),和 QMetaEnum.isFlag ().

bool QMetaProperty.isReadable ( self )

Returns true if this property is readable; otherwise returns false.

另请参阅 isWritable (), read (),和 isValid ().

bool QMetaProperty.isResettable ( self )

Returns true if this property can be reset to a default value; otherwise returns false.

另请参阅 reset ().

bool QMetaProperty.isScriptable ( self , QObject   object  = None)

Returns true if the property is scriptable for the given object ;否则返回 false。

若无 object is given, the function returns false if the Q_PROPERTY() 's SCRIPTABLE attribute is false; otherwise returns true (if the attribute is true or is a function or expression).

另请参阅 isDesignable () 和 isStored ().

bool QMetaProperty.isStored ( self , QObject   object  = None)

Returns true if the property is stored for object ; otherwise returns false.

若无 object is given, the function returns false if the Q_PROPERTY() 's STORED attribute is false; otherwise returns true (if the attribute is true or is a function or expression).

另请参阅 isDesignable () 和 isScriptable ().

bool QMetaProperty.isUser ( self , QObject   object  = None)

Returns true if this property is designated as the USER property, i.e., the one that the user can edit for object or that is significant in some other way. Otherwise it returns false. e.g., the text property is the USER editable property of a QLineEdit .

object is null, the function returns false if the Q_PROPERTY() 's USER attribute is false. Otherwise it returns true.

另请参阅 QMetaObject.userProperty (), isDesignable (),和 isScriptable ().

bool QMetaProperty.isValid ( self )

Returns true if this property is valid (readable); otherwise returns false.

另请参阅 isReadable ().

bool QMetaProperty.isWritable ( self )

Returns true if this property is writable; otherwise returns false.

另请参阅 isReadable () 和 write ().

str QMetaProperty.name ( self )

Returns this property's name.

另请参阅 type () 和 typeName ().

QMetaMethod QMetaProperty.notifySignal ( self )

返回 QMetaMethod instance of the property change notifying signal if one was specified, otherwise returns an invalid QMetaMethod .

该函数在 Qt 4.5 引入。

另请参阅 hasNotifySignal ().

int QMetaProperty.notifySignalIndex ( self )

Returns the index of the property change notifying signal if one was specified, otherwise returns -1.

该函数在 Qt 4.6 引入。

另请参阅 hasNotifySignal ().

int QMetaProperty.propertyIndex ( self )

Returns this property's index.

该函数在 Qt 4.6 引入。

QVariant QMetaProperty.read ( self , QObject   obj )

Reads the property's value from the given object 。返回 the value if it was able to read it; otherwise returns an invalid variant.

另请参阅 write (), reset (),和 isReadable ().

bool QMetaProperty.reset ( self , QObject   obj )

Resets the property for the given object with a reset method. Returns true if the reset worked; otherwise returns false.

Reset methods are optional; only a few properties support them.

另请参阅 read () 和 write ().

Type QMetaProperty.type ( self )

Returns this property's type. The return value is one of the values of the QVariant.Type enumeration.

另请参阅 userType (), typeName (),和 name ().

str QMetaProperty.typeName ( self )

Returns the name of this property's type.

另请参阅 type () 和 name ().

int QMetaProperty.userType ( self )

Returns this property's user type. The return value is one of the values that are registered with QMetaType , or 0 if the type is not registered.

该函数在 Qt 4.2 引入。

另请参阅 type (), QMetaType ,和 typeName ().

bool QMetaProperty.write ( self , QObject   obj , QVariant  value )

写入 value as the property's value to the given object . Returns true if the write succeeded; otherwise returns false.

另请参阅 read (), reset (),和 isWritable ().