QMetaProperty¶
The
QMetaProperty
class 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’s 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’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¶
QMetaProperty
objects 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’s type is an enumerator type; otherwise the returned value is undefined.
See also
- PySide2.QtCore.QMetaProperty.hasNotifySignal()¶
- Return type:
bool
Returns
true
if this property has a corresponding change notify signal; otherwise returnsfalse
.See also
- PySide2.QtCore.QMetaProperty.hasStdCppSet()¶
- Return type:
bool
Returns
true
if the property has a C++ setter function that follows Qt’s standard “name” / “setName” 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
true
if the property is constant; otherwise returnsfalse
.A property is constant if the
Q_PROPERTY()
‘sCONSTANT
attribute is set.
- PySide2.QtCore.QMetaProperty.isDesignable([obj=None])¶
- Parameters:
obj –
PySide2.QtCore.QObject
- Return type:
bool
Returns
true
if this property is designable for the givenobject
; otherwise returnsfalse
.If no
object
is given, the function returnsfalse
if theQ_PROPERTY()
‘sDESIGNABLE
attribute 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
true
if the property is editable for the givenobject
; otherwise returnsfalse
.If no
object
is given, the function returnsfalse
if theQ_PROPERTY()
‘sEDITABLE
attribute 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
true
if the property’s type is an enumeration value; otherwise returnsfalse
.See also
- PySide2.QtCore.QMetaProperty.isFinal()¶
- Return type:
bool
Returns
true
if the property is final; otherwise returnsfalse
.A property is final if the
Q_PROPERTY()
‘sFINAL
attribute is set.
- PySide2.QtCore.QMetaProperty.isFlagType()¶
- Return type:
bool
Returns
true
if 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
- PySide2.QtCore.QMetaProperty.isReadable()¶
- Return type:
bool
Returns
true
if this property is readable; otherwise returnsfalse
.See also
- PySide2.QtCore.QMetaProperty.isRequired()¶
- Return type:
bool
Returns
true
if the property is required; otherwise returnsfalse
.A property is final if the
Q_PROPERTY()
‘sREQUIRED
attribute is set.
- PySide2.QtCore.QMetaProperty.isResettable()¶
- Return type:
bool
Returns
true
if 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
true
if the property is scriptable for the givenobject
; otherwise returnsfalse
.If no
object
is given, the function returnsfalse
if theQ_PROPERTY()
‘sSCRIPTABLE
attribute 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
true
if the property is stored forobject
; otherwise returns false.If no
object
is given, the function returnsfalse
if theQ_PROPERTY()
‘sSTORED
attribute 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
true
if this property is designated as theUSER
property, i.e., the one that the user can edit forobject
or that is significant in some other way. Otherwise it returns false. e.g., thetext
property is theUSER
editable property of aQLineEdit
.If
object
isNone
, the function returnsfalse
if theQ_PROPERTY()
‘sUSER
attribute is false. Otherwise it returns true.See also
- PySide2.QtCore.QMetaProperty.isValid()¶
- Return type:
bool
Returns
true
if this property is valid (readable); otherwise returnsfalse
.See also
- PySide2.QtCore.QMetaProperty.isWritable()¶
- Return type:
bool
Returns
true
if this property is writable; otherwise returns false.See also
- PySide2.QtCore.QMetaProperty.name()¶
- Return type:
str
Returns this property’s name.
See also
- PySide2.QtCore.QMetaProperty.notifySignal()¶
- Return type:
Returns the
QMetaMethod
instance 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’s index.
- PySide2.QtCore.QMetaProperty.read(obj)¶
- Parameters:
obj –
PySide2.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.See also
- PySide2.QtCore.QMetaProperty.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
- PySide2.QtCore.QMetaProperty.relativePropertyIndex()¶
- Return type:
int
Returns this property’s 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
object
with a reset method. Returnstrue
if 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
gadget
with a reset method. Returnstrue
if 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’s type. The return value is one of the values of the
Type
enumeration.See also
- PySide2.QtCore.QMetaProperty.typeName()¶
- Return type:
str
Returns the name of this property’s type.
- PySide2.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
, orUnknownType
if the type is not registered.See also
type()
QMetaType
typeName()
- PySide2.QtCore.QMetaProperty.write(obj, value)¶
- Parameters:
obj –
PySide2.QtCore.QObject
value – object
- Return type:
bool
Writes
value
as the property’s value to the givenobject
. Returns true if the write succeeded; otherwise returnsfalse
.If
value
is 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 –
void
value – object
- Return type:
bool
Writes
value
as 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
© 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.