|  | Home · All Classes · Modules

# QMetaProperty Class Reference
[QtCore module]

The QMetaProperty class provides meta-data about a property. More...

### Methods

- __init__ (self)
- __init__ (self, QMetaProperty other)
- QMetaEnum enumerator (self)
- bool hasStdCppSet (self)
- bool isDesignable (self, QObject obj = None)
- bool isEditable (self, QObject obj = None)
- bool isEnumType (self)
- bool isFlagType (self)
- bool isReadable (self)
- bool isResettable (self)
- bool isScriptable (self, QObject obj = None)
- bool isStored (self, QObject obj = None)
- bool isUser (self, QObject obj = None)
- bool isValid (self)
- bool isWritable (self)
- str name (self)
- QVariant read (self, QObject obj)
- bool reset (self, QObject obj)
- QVariant.Type type (self)
- str typeName (self)
- int userType (self)
- bool write (self, QObject obj, QVariant value)

## Detailed Description

The QMetaProperty class provides meta-data about a property.

A property has a name() and a type(), as well as various attributes that specify its behavior: isReadable(), isWritable(), isDesignable(), isScriptable(), and 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() and isFlagType() both return true. The enumerator for these types is available from enumerator().

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

You get property meta-data through an object's meta-object. See QMetaObject.property() and QMetaObject.propertyCount() for details.

See also QMetaObject, QMetaEnum, QMetaMethod, and Qt's Property System.

## Method Documentation

### QMetaProperty.__init__ (self)

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

### QMetaEnum QMetaProperty.enumerator (self)

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

See also isEnumType() and isFlagType().

### bool QMetaProperty.hasStdCppSet (self)

### bool QMetaProperty.isDesignable (self, QObject obj = None)

Returns true if this property is designable for the given object; otherwise returns false.

If no 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).

See also isScriptable() and isStored().

### bool QMetaProperty.isEditable (self, QObject obj = None)

### bool QMetaProperty.isEnumType (self)

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

See also enumerator() and isFlagType().

### 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.

See also isEnumType(), enumerator(), and QMetaEnum.isFlag().

### bool QMetaProperty.isReadable (self)

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

See also isWritable(), read(), and isValid().

### bool QMetaProperty.isResettable (self)

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

See also reset().

### bool QMetaProperty.isScriptable (self, QObject obj = None)

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

If no 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).

See also isDesignable() and isStored().

### bool QMetaProperty.isStored (self, QObject obj = None)

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

If no 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).

See also isDesignable() and isScriptable().

### bool QMetaProperty.isUser (self, QObject obj = 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.

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

See also QMetaObject.userProperty(), isDesignable(), and isScriptable().

### bool QMetaProperty.isValid (self)

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

See also isReadable().

### bool QMetaProperty.isWritable (self)

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

See also isReadable() and write().

### str QMetaProperty.name (self)

Returns this property's name.

See also type() and typeName().

### QVariant QMetaProperty.read (self, QObject obj)

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

See also write(), reset(), and 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.

See also read() and write().

### QVariant.Type QMetaProperty.type (self)

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

See also userType(), typeName(), and name().

### str QMetaProperty.typeName (self)

Returns the name of this property's type.

See also type() and 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.

This function was introduced in Qt 4.2.

See also type(), QMetaType, and typeName().

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

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

See also read(), reset(), and isWritable().