QMetaProperty露
The
QMetaPropertyclass provides meta-data about a property. More鈥

Synopsis露
Functions露
def
enumerator()def
hasNotifySignal()def
hasStdCppSet()def
isConstant()def
isDesignable([obj=None])def
isEditable([obj=None])def
isEnumType()def
isFinal()def
isFlagType()def
isReadable()def
isRequired()def
isResettable()def
isScriptable([obj=None])def
isStored([obj=None])def
isUser([obj=None])def
isValid()def
isWritable()def
name()def
notifySignal()def
notifySignalIndex()def
propertyIndex()def
read(obj)def
readOnGadget(gadget)def
relativePropertyIndex()def
reset(obj)def
resetOnGadget(gadget)def
revision()def
type()def
typeName()def
userType()def
write(obj, value)def
writeOnGadget(gadget, value)
Detailed Description露
Property meta-data is obtained from an object鈥檚 meta-object. See
property()andpropertyCount()for details.
Property Meta-Data露
A property has a
name()and atype(), 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鈥檚 values are set and retrieved with
read(),write(), andreset(); they can also be changed throughQObject鈥榮 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.
- class PySide2.QtCore.QMetaProperty露
PySide2.QtCore.QMetaProperty(QMetaProperty)
- Parameters:
QMetaProperty 鈥
PySide2.QtCore.QMetaProperty
- PySide2.QtCore.QMetaProperty.enumerator()露
- Return type:
Returns the enumerator if this property鈥檚 type is an enumerator type; otherwise the returned value is undefined.
See also
- PySide2.QtCore.QMetaProperty.hasNotifySignal()露
- Return type:
bool
Returns
trueif this property has a corresponding change notify signal; otherwise returnsfalse.See also
- PySide2.QtCore.QMetaProperty.hasStdCppSet()露
- Return type:
bool
Returns
trueif the property has a C++ setter function that follows Qt鈥檚 standard 鈥渘ame鈥 / 鈥渟etName鈥 pattern. Designer and uic query in order to avoid expensivesetProperty()calls. All properties in Qt [should] follow this pattern.
- PySide2.QtCore.QMetaProperty.isConstant()露
- Return type:
bool
Returns
trueif the property is constant; otherwise returnsfalse.A property is constant if the
Q_PROPERTY()鈥榮CONSTANTattribute is set.
- PySide2.QtCore.QMetaProperty.isDesignable([obj=None])露
- Parameters:
obj 鈥
PySide2.QtCore.QObject- Return type:
bool
Returns
trueif this property is designable for the givenobject; otherwise returnsfalse.If no
objectis given, the function returnsfalseif theQ_PROPERTY()鈥榮DESIGNABLEattribute is false; otherwise returnstrue(if the attribute is true or is a function or expression).See also
- PySide2.QtCore.QMetaProperty.isEditable([obj=None])露
- Parameters:
obj 鈥
PySide2.QtCore.QObject- Return type:
bool
Note
This function is deprecated.
Returns
trueif the property is editable for the givenobject; otherwise returnsfalse.If no
objectis given, the function returnsfalseif theQ_PROPERTY()鈥榮EDITABLEattribute is false; otherwise returns true (if the attribute is true or is a function or expression).See also
- PySide2.QtCore.QMetaProperty.isEnumType()露
- Return type:
bool
Returns
trueif the property鈥檚 type is an enumeration value; otherwise returnsfalse.See also
- PySide2.QtCore.QMetaProperty.isFinal()露
- Return type:
bool
Returns
trueif the property is final; otherwise returnsfalse.A property is final if the
Q_PROPERTY()鈥榮FINALattribute is set.
- PySide2.QtCore.QMetaProperty.isFlagType()露
- Return type:
bool
Returns
trueif the property鈥檚 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
- PySide2.QtCore.QMetaProperty.isReadable()露
- Return type:
bool
Returns
trueif this property is readable; otherwise returnsfalse.See also
- PySide2.QtCore.QMetaProperty.isRequired()露
- Return type:
bool
Returns
trueif the property is required; otherwise returnsfalse.A property is final if the
Q_PROPERTY()鈥榮REQUIREDattribute is set.
- PySide2.QtCore.QMetaProperty.isResettable()露
- Return type:
bool
Returns
trueif this property can be reset to a default value; otherwise returnsfalse.See also
- PySide2.QtCore.QMetaProperty.isScriptable([obj=None])露
- Parameters:
obj 鈥
PySide2.QtCore.QObject- Return type:
bool
Returns
trueif the property is scriptable for the givenobject; otherwise returnsfalse.If no
objectis given, the function returnsfalseif theQ_PROPERTY()鈥榮SCRIPTABLEattribute is false; otherwise returns true (if the attribute is true or is a function or expression).See also
- PySide2.QtCore.QMetaProperty.isStored([obj=None])露
- Parameters:
obj 鈥
PySide2.QtCore.QObject- Return type:
bool
Returns
trueif the property is stored forobject; otherwise returns false.If no
objectis given, the function returnsfalseif theQ_PROPERTY()鈥榮STOREDattribute is false; otherwise returns true (if the attribute is true or is a function or expression).See also
- PySide2.QtCore.QMetaProperty.isUser([obj=None])露
- Parameters:
obj 鈥
PySide2.QtCore.QObject- Return type:
bool
Returns
trueif this property is designated as theUSERproperty, i.e., the one that the user can edit forobjector that is significant in some other way. Otherwise it returns false. e.g., thetextproperty is theUSEReditable property of aQLineEdit.If
objectisNone, the function returnsfalseif theQ_PROPERTY()鈥榮USERattribute is false. Otherwise it returns true.See also
- PySide2.QtCore.QMetaProperty.isValid()露
- Return type:
bool
Returns
trueif this property is valid (readable); otherwise returnsfalse.See also
- PySide2.QtCore.QMetaProperty.isWritable()露
- Return type:
bool
Returns
trueif this property is writable; otherwise returns false.See also
- PySide2.QtCore.QMetaProperty.name()露
- Return type:
str
Returns this property鈥檚 name.
See also
- PySide2.QtCore.QMetaProperty.notifySignal()露
- Return type:
Returns the
QMetaMethodinstance of the property change notifying signal if one was specified, otherwise returns an invalidQMetaMethod.See also
- PySide2.QtCore.QMetaProperty.notifySignalIndex()露
- Return type:
int
Returns the index of the property change notifying signal if one was specified, otherwise returns -1.
See also
- PySide2.QtCore.QMetaProperty.propertyIndex()露
- Return type:
int
Returns this property鈥檚 index.
- PySide2.QtCore.QMetaProperty.read(obj)露
- Parameters:
obj 鈥
PySide2.QtCore.QObject- Return type:
object
Reads the property鈥檚 value from the given
object. Returns the value if it was able to read it; otherwise returns an invalid variant.See also
- PySide2.QtCore.QMetaProperty.readOnGadget(gadget)露
- Parameters:
gadget 鈥
void- Return type:
object
Reads the property鈥檚 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
- PySide2.QtCore.QMetaProperty.relativePropertyIndex()露
- Return type:
int
Returns this property鈥檚 index relative within the enclosing meta object.
- PySide2.QtCore.QMetaProperty.reset(obj)露
- Parameters:
obj 鈥
PySide2.QtCore.QObject- Return type:
bool
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.
- PySide2.QtCore.QMetaProperty.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
- PySide2.QtCore.QMetaProperty.revision()露
- Return type:
int
Returns the property revision if one was specified by REVISION, otherwise returns 0.
- PySide2.QtCore.QMetaProperty.type()露
- Return type:
QVariant::Type
Returns this property鈥檚 type. The return value is one of the values of the
Typeenumeration.See also
- PySide2.QtCore.QMetaProperty.typeName()露
- Return type:
str
Returns the name of this property鈥檚 type.
- PySide2.QtCore.QMetaProperty.userType()露
- Return type:
int
Returns this property鈥檚 user type. The return value is one of the values that are registered with
QMetaType, orUnknownTypeif the type is not registered.See also
type()QMetaTypetypeName()
- PySide2.QtCore.QMetaProperty.write(obj, value)露
- Parameters:
obj 鈥
PySide2.QtCore.QObjectvalue 鈥 object
- Return type:
bool
Writes
valueas the property鈥檚 value to the givenobject. Returns true if the write succeeded; otherwise returnsfalse.If
valueis not of the same type 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.See also
- PySide2.QtCore.QMetaProperty.writeOnGadget(gadget, value)露
- Parameters:
gadget 鈥
voidvalue 鈥 object
- Return type:
bool
Writes
valueas the property鈥檚 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
漏 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.