QMetaProperty

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

Inheritance diagram of PySide6.QtCore.QMetaProperty

Synopsis

Functions

Detailed Description

Property meta-data is obtained from an object’s meta-object. See property() and propertyCount() for details.

Property Meta-Data

A property has a name() and a , as well as various attributes that specify its behavior: isReadable() , isWritable() , isDesignable() , isScriptable() , revision() , 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 setProperty() and 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.

class PySide6.QtCore.QMetaProperty

PySide6.QtCore.QMetaProperty(QMetaProperty)

Parameters

QMetaPropertyPySide6.QtCore.QMetaProperty

PySide6.QtCore.QMetaProperty.enumerator()
Return type

PySide6.QtCore.QMetaEnum

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

PySide6.QtCore.QMetaProperty.hasNotifySignal()
Return type

bool

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

See also

notifySignal()

PySide6.QtCore.QMetaProperty.hasStdCppSet()
Return type

bool

PySide6.QtCore.QMetaProperty.isAlias()
Return type

bool

PySide6.QtCore.QMetaProperty.isBindable()
Return type

bool

Returns true if the Q_PROPERTY() exposes binding functionality; otherwise returns false.

This implies that you can create bindings that use this property as a dependency or install QPropertyObserver objects on this property. Unless the property is readonly, you can also set a binding on this property.

See also

QProperty isWritable() bindable()

PySide6.QtCore.QMetaProperty.isConstant()
Return type

bool

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

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

PySide6.QtCore.QMetaProperty.isDesignable()
Return type

bool

Returns false if the Q_PROPERTY()’s DESIGNABLE attribute is false; otherwise returns true.

PySide6.QtCore.QMetaProperty.isEnumType()
Return type

bool

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

PySide6.QtCore.QMetaProperty.isFinal()
Return type

bool

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

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

PySide6.QtCore.QMetaProperty.isFlagType()
Return type

bool

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.

PySide6.QtCore.QMetaProperty.isReadable()
Return type

bool

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

PySide6.QtCore.QMetaProperty.isRequired()
Return type

bool

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

A property is final if the Q_PROPERTY()’s REQUIRED attribute is set.

PySide6.QtCore.QMetaProperty.isResettable()
Return type

bool

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

See also

reset()

PySide6.QtCore.QMetaProperty.isScriptable()
Return type

bool

Returns false if the Q_PROPERTY()’s SCRIPTABLE attribute is false; otherwise returns true.

PySide6.QtCore.QMetaProperty.isStored()
Return type

bool

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

The function returns false if the Q_PROPERTY()’s STORED attribute is false; otherwise returns true.

PySide6.QtCore.QMetaProperty.isUser()
Return type

bool

Returns false if the Q_PROPERTY()’s USER attribute is false. Otherwise it returns true, indicating the property is designated as the USER property, i.e., the one that the user can edit or that is significant in some other way.

PySide6.QtCore.QMetaProperty.isValid()
Return type

bool

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

See also

isReadable()

PySide6.QtCore.QMetaProperty.isWritable()
Return type

bool

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

PySide6.QtCore.QMetaProperty.metaType()
Return type

PySide6.QtCore.QMetaType

Returns this property’s QMetaType .

See also

QMetaType

PySide6.QtCore.QMetaProperty.name()
Return type

str

Returns this property’s name.

See also

type() typeName()

PySide6.QtCore.QMetaProperty.notifySignal()
Return type

PySide6.QtCore.QMetaMethod

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

PySide6.QtCore.QMetaProperty.notifySignalIndex()
Return type

int

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

PySide6.QtCore.QMetaProperty.propertyIndex()
Return type

int

Returns this property’s index.

PySide6.QtCore.QMetaProperty.read(obj)
Parameters

objPySide6.QtCore.QObject

Return type

object

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

PySide6.QtCore.QMetaProperty.readOnGadget(gadget)
Parameters

gadgetvoid

Return type

object

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

This function should only be used if this is a property of a Q_GADGET

PySide6.QtCore.QMetaProperty.relativePropertyIndex()
Return type

int

Returns this property’s index relative within the enclosing meta object.

PySide6.QtCore.QMetaProperty.reset(obj)
Parameters

objPySide6.QtCore.QObject

Return type

bool

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

PySide6.QtCore.QMetaProperty.resetOnGadget(gadget)
Parameters

gadgetvoid

Return type

bool

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

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

This function should only be used if this is a property of a Q_GADGET

PySide6.QtCore.QMetaProperty.revision()
Return type

int

Returns the property revision if one was specified by REVISION, otherwise returns 0.

PySide6.QtCore.QMetaProperty.typeId()
Return type

int

Returns the storage type of the property. This is the same as metaType() .id().

PySide6.QtCore.QMetaProperty.typeName()
Return type

str

Returns the name of this property’s type.

See also

type() name()

PySide6.QtCore.QMetaProperty.userType()
Return type

int

Returns this property’s user type. The return value is one of the values that are registered with QMetaType .

This is equivalent to metaType() .id()

See also

type() QMetaType typeName() metaType()

PySide6.QtCore.QMetaProperty.write(obj, value)
Parameters
Return type

bool

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

If value is not of the same type type as the property, a conversion is attempted. An empty QVariant() is equivalent to a call to reset() if this property is resetable, or setting a default-constructed object otherwise.

PySide6.QtCore.QMetaProperty.writeOnGadget(gadget, value)
Parameters
  • gadgetvoid

  • value – object

Return type

bool

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

This function should only be used if this is a property of a Q_GADGET