PySide6.QtCore.QMetaProperty¶
- class QMetaProperty¶
The
QMetaPropertyclass provides meta-data about a property. More…Synopsis¶
Methods¶
def
__init__()def
enumerator()def
hasStdCppSet()def
isAlias()def
isBindable()def
isConstant()def
isDesignable()def
isEnumType()def
isFinal()def
isFlagType()def
isReadable()def
isRequired()def
isResettable()def
isScriptable()def
isStored()def
isUser()def
isValid()def
isWritable()def
metaType()def
name()def
notifySignal()def
propertyIndex()def
read()def
readOnGadget()def
reset()def
resetOnGadget()def
revision()def
typeId()def
typeName()def
userType()def
write()def
writeOnGadget()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
Property meta-data is obtained from an object’s meta-object. See
property()andpropertyCount()for details.Property Meta-Data¶
A property has a
name()and ametaType(), as well as various attributes that specify its behavior:isReadable(),isWritable(),isDesignable(),isScriptable(),revision(), andisStored().If the property is an enumeration,
isEnumType()returnstrue; if the property is an enumeration that is also a flag (i.e. its values can be combined using the OR operator),isEnumType()andisFlagType()both return true. The enumerator for these types is available fromenumerator().The property’s values are set and retrieved with
read(),write(), andreset(); they can also be changed throughQObject‘s set and get functions. SeesetProperty()andproperty()for details.Copying and Assignment¶
QMetaPropertyobjects can be copied by value. However, each copy will refer to the same underlying property meta-data.- __init__()¶
Returns the enumerator if this property’s type is an enumerator type; otherwise the returned value is undefined.
See also
- hasNotifySignal()¶
- Return type:
bool
Returns
trueif this property has a corresponding change notify signal; otherwise returnsfalse.See also
- hasStdCppSet()¶
- Return type:
bool
- isAlias()¶
- Return type:
bool
- isBindable()¶
- Return type:
bool
Returns
trueif theQ_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
QPropertyisWritable()bindable()- isConstant()¶
- Return type:
bool
Returns
trueif the property is constant; otherwise returnsfalse.A property is constant if the
Q_PROPERTY()'sCONSTANTattribute is set.- isDesignable()¶
- Return type:
bool
Returns
falseif theQ_PROPERTY()'sDESIGNABLEattribute is false; otherwise returnstrue.See also
- isEnumType()¶
- Return type:
bool
Returns
trueif the property’s type is an enumeration value; otherwise returnsfalse.See also
- isFinal()¶
- Return type:
bool
Returns
trueif the property is final; otherwise returnsfalse.A property is final if the
Q_PROPERTY()'sFINALattribute is set.- isFlagType()¶
- Return type:
bool
Returns
trueif the property’s type is an enumeration value that is used as a flag; otherwise returnsfalse.Flags can be combined using the OR operator. A flag type is implicitly also an enum type.
See also
- isReadable()¶
- Return type:
bool
Returns
trueif this property is readable; otherwise returnsfalse.See also
- isRequired()¶
- Return type:
bool
Returns
trueif the property is required; otherwise returnsfalse.A property is final if the
Q_PROPERTY()'sREQUIREDattribute is set.- isResettable()¶
- Return type:
bool
Returns
trueif this property can be reset to a default value; otherwise returnsfalse.See also
- isScriptable()¶
- Return type:
bool
Returns
falseif theQ_PROPERTY()'sSCRIPTABLEattribute is false; otherwise returns true.See also
- isStored()¶
- Return type:
bool
Returns
trueif the property is stored; otherwise returns false.The function returns
falseif theQ_PROPERTY()'sSTOREDattribute is false; otherwise returns true.See also
- isUser()¶
- Return type:
bool
Returns
falseif theQ_PROPERTY()'sUSERattribute is false. Otherwise it returns true, indicating the property is designated as theUSERproperty, i.e., the one that the user can edit or that is significant in some other way.See also
- isValid()¶
- Return type:
bool
Returns
trueif this property is valid (readable); otherwise returnsfalse.See also
- isWritable()¶
- Return type:
bool
Returns
trueif this property is writable; otherwise returns false.See also
Returns this property’s
QMetaType.See also
- name()¶
- Return type:
str
Returns this property’s name.
See also
type()typeName()- notifySignal()¶
- Return type:
Returns the
QMetaMethodinstance of the property change notifying signal if one was specified, otherwise returns an invalidQMetaMethod.See also
- notifySignalIndex()¶
- Return type:
int
Returns the index of the property change notifying signal if one was specified, otherwise returns -1.
See also
- propertyIndex()¶
- Return type:
int
Returns this property’s index.
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
- readOnGadget(gadget)¶
- Parameters:
gadget –
void- 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- relativePropertyIndex()¶
- Return type:
int
Returns this property’s index relative within the enclosing meta object.
Resets the property for the given
objectwith a reset method. Returnstrueif the reset worked; otherwise returnsfalse.Reset methods are optional; only a few properties support them.
- resetOnGadget(gadget)¶
- Parameters:
gadget –
void- Return type:
bool
Resets the property for the given
gadgetwith a reset method. Returnstrueif the reset worked; otherwise returnsfalse.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- revision()¶
- Return type:
int
Returns the property revision if one was specified by
Q_REVISION, otherwise returns 0. Since Qt 6.0, non-zero values are encoded and can be decoded usingfromEncodedVersion().- typeId()¶
- Return type:
int
Returns the storage type of the property. This is the same as
metaType().id().See also
- typeName()¶
- Return type:
str
Returns the name of this property’s type.
See also
type()name()- 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()QMetaTypetypeName()metaType()Writes
valueas the property’s value to the givenobject. Returns true if the write succeeded; otherwise returnsfalse.If
valueis not of the same type as the property, a conversion is attempted. An empty QVariant() is equivalent to a call toreset()if this property is resettable, or setting a default-constructed object otherwise.Note
This function internally makes a copy of
value. Prefer to use the rvalue overload when possible.See also
- writeOnGadget(gadget, value)¶
- Parameters:
gadget –
voidvalue – object
- Return type:
bool
Writes
valueas the property’s value to the givengadget. Returns true if the write succeeded; otherwise returnsfalse.This function should only be used if this is a property of a
Q_GADGET