The QMetaProperty class provides meta-data about a property. 更多...
头: | #include <QMetaProperty> |
qmake: | QT += core |
QMetaEnum | enumerator () const |
bool | hasNotifySignal () const |
bool | isConstant () const |
bool | isDesignable (const QObject * object = nullptr) const |
bool | isEnumType () const |
bool | isFinal () const |
bool | isFlagType () const |
bool | isReadable () const |
bool | isRequired () const |
bool | isResettable () const |
bool | isScriptable (const QObject * object = nullptr) const |
bool | isStored (const QObject * object = nullptr) const |
bool | isUser (const QObject * object = nullptr) const |
bool | isValid () const |
bool | isWritable () const |
const char * | name () const |
QMetaMethod | notifySignal () const |
int | notifySignalIndex () const |
int | propertyIndex () const |
QVariant | read (const QObject * object ) const |
QVariant | readOnGadget (const void * gadget ) const |
int | relativePropertyIndex () const |
bool | reset (QObject * object ) const |
bool | resetOnGadget (void * gadget ) const |
int | revision () const |
QVariant::Type | type () const |
const char * | typeName () const |
int | userType () const |
bool | write (QObject * object , const QVariant & value ) const |
bool | writeOnGadget (void * gadget , const QVariant & value ) const |
Property meta-data is obtained from an object's meta-object. See QMetaObject::property () 和 QMetaObject::propertyCount () 了解细节。
A property has a name () 和 type (), as well as various attributes that specify its behavior: isReadable (), isWritable (), isDesignable (), isScriptable (), revision (),和 isStored ().
If the property is an enumeration,
isEnumType
() 返回
true
; if the property is an enumeration that is also a flag (i.e. its values can be combined using the OR operator),
isEnumType
() 和
isFlagType
() both return true. The enumerator for these types is available from
enumerator
().
The property's values are set and retrieved with read (), write (),和 reset (); they can also be changed through QObject 's set and get functions. See QObject::setProperty () 和 QObject::property () 了解细节。
QMetaProperty objects can be copied by value. However, each copy will refer to the same underlying property meta-data.
另请参阅 QMetaObject , QMetaEnum , QMetaMethod ,和 Qt 的特性系统 .
Returns the enumerator if this property's type is an enumerator type; otherwise the returned value is undefined.
另请参阅 isEnumType () 和 isFlagType ().
返回
true
if this property has a corresponding change notify signal; otherwise returns
false
.
另请参阅 notifySignal ().
返回
true
if the property is constant; otherwise returns
false
.
A property is constant if the
Q_PROPERTY()
's
CONSTANT
属性有设置。
该函数在 Qt 4.6 引入。
返回
true
if this property is designable for the given
object
;否则返回
false
.
若无
object
is given, the function returns
false
若
Q_PROPERTY()
's
DESIGNABLE
attribute is false; otherwise returns
true
(if the attribute is true or is a function or expression).
另请参阅 isScriptable () 和 isStored ().
返回
true
if the property's type is an enumeration value; otherwise returns
false
.
另请参阅 enumerator () 和 isFlagType ().
返回
true
if the property is final; otherwise returns
false
.
A property is final if the
Q_PROPERTY()
's
FINAL
属性有设置。
该函数在 Qt 4.6 引入。
返回
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.
另请参阅 isEnumType (), enumerator (),和 QMetaEnum::isFlag ().
返回
true
if this property is readable; otherwise returns
false
.
另请参阅 isWritable (), read (),和 isValid ().
返回
true
if the property is required; otherwise returns
false
.
A property is final if the
Q_PROPERTY()
's
REQUIRED
属性有设置。
该函数在 Qt 5.15 引入。
返回
true
if this property can be reset to a default value; otherwise returns
false
.
另请参阅 reset ().
返回
true
if the property is scriptable for the given
object
;否则返回
false
.
若无
object
is given, the function returns
false
若
Q_PROPERTY()
's
SCRIPTABLE
attribute is false; otherwise returns true (if the attribute is true or is a function or expression).
另请参阅 isDesignable () 和 isStored ().
返回
true
if the property is stored for
object
;否则返回 false。
若无
object
is given, the function returns
false
若
Q_PROPERTY()
's
STORED
attribute is false; otherwise returns true (if the attribute is true or is a function or expression).
另请参阅 isDesignable () 和 isScriptable ().
返回
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
.
若
object
is
nullptr
,函数返回
false
若
Q_PROPERTY()
's
USER
attribute is false. Otherwise it returns true.
另请参阅 QMetaObject::userProperty (), isDesignable (),和 isScriptable ().
返回
true
if this property is valid (readable); otherwise returns
false
.
另请参阅 isReadable ().
返回
true
if this property is writable; otherwise returns false.
另请参阅 isReadable () 和 write ().
Returns this property's name.
返回 QMetaMethod instance of the property change notifying signal if one was specified, otherwise returns an invalid QMetaMethod .
该函数在 Qt 4.5 引入。
另请参阅 hasNotifySignal ().
Returns the index of the property change notifying signal if one was specified, otherwise returns -1.
该函数在 Qt 4.6 引入。
另请参阅 hasNotifySignal ().
Returns this property's index.
该函数在 Qt 4.6 引入。
Reads the property's value from the given object . Returns the value if it was able to read it; otherwise returns an invalid variant.
另请参阅 write (), reset (),和 isReadable ().
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
该函数在 Qt 5.5 引入。
Returns this property's index relative within the enclosing meta object.
该函数在 Qt 5.14 引入。
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.
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
该函数在 Qt 5.5 引入。
Returns the property revision if one was specified by REVISION, otherwise returns 0.
该函数在 Qt 5.1 引入。
Returns this property's type. The return value is one of the values of the QVariant::Type enumeration.
另请参阅 userType (), typeName (),和 name ().
Returns the name of this property's type.
Returns this property's user type. The return value is one of the values that are registered with QMetaType ,或 QMetaType::UnknownType if the type is not registered.
该函数在 Qt 4.2 引入。
另请参阅 type (), QMetaType ,和 typeName ().
写入
value
as the property's value to the given
object
. Returns true if the write succeeded; otherwise returns
false
.
若 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 resettable, or setting a default-constructed object otherwise.
另请参阅 read (), reset (),和 isWritable ().
写入
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
该函数在 Qt 5.5 引入。