Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QMetaProperty Class Reference

\inmodule QtCore More...

#include <qmetaobject.h>

+ Collaboration diagram for QMetaProperty:

Public Member Functions

constexpr QMetaProperty ()
 
const char * name () const
 Returns this property's name.
 
const char * typeName () const
 Returns the name of this property's type.
 
int userType () const
 
int typeId () const
 
QMetaType metaType () const
 
int propertyIndex () const
 
int relativePropertyIndex () const
 
bool isReadable () const
 Returns true if this property is readable; otherwise returns false.
 
bool isWritable () const
 Returns true if this property is writable; otherwise returns false.
 
bool isResettable () const
 Returns true if this property can be reset to a default value; otherwise returns false.
 
bool isDesignable () const
 Returns false if the {Q_PROPERTY()}'s DESIGNABLE attribute is false; otherwise returns true.
 
bool isScriptable () const
 Returns false if the {Q_PROPERTY()}'s SCRIPTABLE attribute is false; otherwise returns true.
 
bool isStored () const
 Returns true if the property is stored; otherwise returns false.
 
bool isUser () const
 Returns false if the {Q_PROPERTY()}'s USER attribute is false.
 
bool isConstant () const
 
bool isFinal () const
 
bool isRequired () const
 
bool isBindable () const
 
bool isFlagType () const
 Returns true if the property's type is an enumeration value that is used as a flag; otherwise returns false.
 
bool isEnumType () const
 Returns true if the property's type is an enumeration value; otherwise returns false.
 
QMetaEnum enumerator () const
 Returns the enumerator if this property's type is an enumerator type; otherwise the returned value is undefined.
 
bool hasNotifySignal () const
 Returns true if this property has a corresponding change notify signal; otherwise returns false.
 
QMetaMethod notifySignal () const
 
int notifySignalIndex () const
 
int revision () const
 
QVariant read (const QObject *obj) const
 Reads the property's value from the given object.
 
bool write (QObject *obj, const QVariant &value) const
 Writes value as the property's value to the given object.
 
bool write (QObject *obj, QVariant &&value) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool reset (QObject *obj) const
 Resets the property for the given object with a reset method.
 
QUntypedBindable bindable (QObject *object) const
 
QVariant readOnGadget (const void *gadget) const
 
bool writeOnGadget (void *gadget, const QVariant &value) const
 
bool writeOnGadget (void *gadget, QVariant &&value) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool resetOnGadget (void *gadget) const
 
bool hasStdCppSet () const
 
bool isAlias () const
 
bool isValid () const
 Returns true if this property is valid (readable); otherwise returns false.
 
const QMetaObjectenclosingMetaObject () const
 

Friends

struct QMetaObject
 
struct QMetaObjectPrivate
 

Detailed Description

\inmodule QtCore

The QMetaProperty class provides meta-data about a property.

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

Definition at line 323 of file qmetaobject.h.

Constructor & Destructor Documentation

◆ QMetaProperty()

QMetaProperty::QMetaProperty ( )
inlineconstexpr

Definition at line 326 of file qmetaobject.h.

Member Function Documentation

◆ bindable()

QUntypedBindable QMetaProperty::bindable ( QObject * object) const
Since
6.0 Returns the bindable interface for the property on a given object.

If the property doesn't support bindings, the returned interface will be invalid.

See also
QObjectBindableProperty, QProperty, isBindable()

Definition at line 3846 of file qmetaobject.cpp.

References bindable(), QMetaObject::BindableProperty, QMetaObject::metacall(), and QMetaObject::propertyOffset().

Referenced by QUntypedBindable::QUntypedBindable(), bindable(), QQmlAnyBinding::ofProperty(), QQmlAnyBinding::removeBindingFrom(), and QQmlAnyBinding::takeFrom().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enclosingMetaObject()

const QMetaObject * QMetaProperty::enclosingMetaObject ( ) const
inline

Definition at line 381 of file qmetaobject.h.

◆ enumerator()

QMetaEnum QMetaProperty::enumerator ( ) const

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

See also
isEnumType(), isFlagType()

Definition at line 3701 of file qmetaobject.cpp.

Referenced by QQmlPropertyPrivate::writeEnumProperty().

+ Here is the caller graph for this function:

◆ hasNotifySignal()

bool QMetaProperty::hasNotifySignal ( ) const

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

See also
notifySignal()

Definition at line 3938 of file qmetaobject.cpp.

Referenced by QQmlWatchProxy::QQmlWatchProxy(), QUntypedBindable::QUntypedBindable(), QMetaObjectBuilder::addProperty(), QQmlProperty::connectNotifySignal(), QQmlProperty::connectNotifySignal(), and QQmlPropertyPrivate::findSignalByName().

+ Here is the caller graph for this function:

◆ hasStdCppSet()

bool QMetaProperty::hasStdCppSet ( ) const

Returns true if the property has a C++ setter function that follows Qt's standard "name" / "setName" pattern. Designer and uic query hasStdCppSet() in order to avoid expensive QObject::setProperty() calls. All properties in Qt [should] follow this pattern.

Definition at line 3618 of file qmetaobject.cpp.

References StdCppSet.

Referenced by QMetaObjectBuilder::addProperty().

+ Here is the caller graph for this function:

◆ isAlias()

bool QMetaProperty::isAlias ( ) const

Returns true if the property is an alias. This is for instance true for a property declared in QML as 'property alias'.

Definition at line 3632 of file qmetaobject.cpp.

References Alias.

◆ isBindable()

bool QMetaProperty::isBindable ( ) const
Since
6.0 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()

Definition at line 4130 of file qmetaobject.cpp.

References Bindable.

Referenced by QUntypedBindable::QUntypedBindable(), and removePendingQPropertyBinding().

+ Here is the caller graph for this function:

◆ isConstant()

bool QMetaProperty::isConstant ( ) const
Since
4.6 Returns true if the property is constant; otherwise returns false.

A property is constant if the {Q_PROPERTY()}'s CONSTANT attribute is set.

Definition at line 4086 of file qmetaobject.cpp.

References Constant.

Referenced by QMetaObjectBuilder::addProperty(), and QQmlProperty::needsNotifySignal().

+ Here is the caller graph for this function:

◆ isDesignable()

bool QMetaProperty::isDesignable ( ) const

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

See also
isScriptable(), isStored()

Definition at line 4027 of file qmetaobject.cpp.

References Designable.

Referenced by QMetaObjectBuilder::addProperty().

+ Here is the caller graph for this function:

◆ isEnumType()

bool QMetaProperty::isEnumType ( ) const

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

See also
enumerator(), isFlagType()

Definition at line 3602 of file qmetaobject.cpp.

References EnumOrFlag.

Referenced by QMetaObjectBuilder::addProperty(), write(), and QQmlPropertyPrivate::writeEnumProperty().

+ Here is the caller graph for this function:

◆ isFinal()

bool QMetaProperty::isFinal ( ) const
Since
4.6 Returns true if the property is final; otherwise returns false.

A property is final if the {Q_PROPERTY()}'s FINAL attribute is set.

Definition at line 4100 of file qmetaobject.cpp.

References Final.

Referenced by QMetaObjectBuilder::addProperty().

+ Here is the caller graph for this function:

◆ isFlagType()

bool QMetaProperty::isFlagType ( ) const

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.

See also
isEnumType(), enumerator(), QMetaEnum::isFlag()

Definition at line 3591 of file qmetaobject.cpp.

Referenced by write(), and QQmlPropertyPrivate::writeEnumProperty().

+ Here is the caller graph for this function:

◆ isReadable()

bool QMetaProperty::isReadable ( ) const

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

See also
isWritable(), read(), isValid()

Definition at line 3925 of file qmetaobject.cpp.

References Readable.

Referenced by QMetaObjectBuilder::addProperty(), allSubObjects(), and propertyNameListForWritableProperties().

+ Here is the caller graph for this function:

◆ isRequired()

bool QMetaProperty::isRequired ( ) const
Since
5.15 Returns true if the property is required; otherwise returns false.

A property is final if the {Q_PROPERTY()}'s REQUIRED attribute is set.

Definition at line 4114 of file qmetaobject.cpp.

References Required.

◆ isResettable()

bool QMetaProperty::isResettable ( ) const

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

See also
reset()

Definition at line 3913 of file qmetaobject.cpp.

References Resettable.

Referenced by QMetaObjectBuilder::addProperty(), reset(), and write().

+ Here is the caller graph for this function:

◆ isScriptable()

bool QMetaProperty::isScriptable ( ) const

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

See also
isDesignable(), isStored()

Definition at line 4040 of file qmetaobject.cpp.

References Scriptable.

Referenced by QMetaObjectBuilder::addProperty().

+ Here is the caller graph for this function:

◆ isStored()

bool QMetaProperty::isStored ( ) const

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.

See also
isDesignable(), isScriptable()

Definition at line 4057 of file qmetaobject.cpp.

References Stored.

Referenced by QMetaObjectBuilder::addProperty().

+ Here is the caller graph for this function:

◆ isUser()

bool QMetaProperty::isUser ( ) const

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.

See also
QMetaObject::userProperty(), isDesignable(), isScriptable()

Definition at line 4072 of file qmetaobject.cpp.

References User.

Referenced by QMetaObjectBuilder::addProperty(), and QMetaObject::userProperty().

+ Here is the caller graph for this function:

◆ isValid()

bool QMetaProperty::isValid ( ) const
inline

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

See also
isReadable()

Definition at line 380 of file qmetaobject.h.

References isReadable().

Referenced by QUntypedBindable::QUntypedBindable(), QQmlBinding::dependencies(), QQmlPropertyPrivate::initProperty(), QQuickMultiPointHandlerPrivate::xMetaProperty(), and QQuickMultiPointHandlerPrivate::yMetaProperty().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isWritable()

bool QMetaProperty::isWritable ( ) const

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

See also
isReadable(), write()

Definition at line 4014 of file qmetaobject.cpp.

References Writable.

Referenced by QMetaObjectBuilder::addProperty(), allSubObjects(), propertyNameListForWritableProperties(), write(), write(), and QQmlPropertyPrivate::writeEnumProperty().

+ Here is the caller graph for this function:

◆ metaType()

QMetaType QMetaProperty::metaType ( ) const

◆ name()

const char * QMetaProperty::name ( ) const

Returns this property's name.

See also
type(), typeName()

Definition at line 3487 of file qmetaobject.cpp.

References rawStringData().

Referenced by QUntypedBindable::QUntypedBindable(), QMetaObjectBuilder::addProperty(), QtAndroidQuickViewEmbedding::addRootObjectSignalListener(), QQuickDesignerSupportProperties::allPropertyNames(), allSubObjects(), VDMListDelegateDataType::createMissingProperties(), QQmlBinding::dependencies(), doWriteProperties(), doWriteProperties(), doWriteProperties(), QQmlContextData::findObjectId(), for(), propertyNameListForWritableProperties(), QQuick3DCustomMaterial::updateSpatialNode(), and QQuick3DEffect::updateSpatialNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ notifySignal()

QMetaMethod QMetaProperty::notifySignal ( ) const
Since
4.5

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

See also
hasNotifySignal()

Definition at line 3953 of file qmetaobject.cpp.

References QMetaObject::method(), and notifySignalIndex().

Referenced by QMetaObjectBuilder::addProperty(), QtAndroidQuickViewEmbedding::addRootObjectSignalListener(), QQmlProperty::connectNotifySignal(), and QQmlPropertyPrivate::findSignalByName().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ notifySignalIndex()

int QMetaProperty::notifySignalIndex ( ) const
Since
4.6

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

See also
hasNotifySignal()

Definition at line 3970 of file qmetaobject.cpp.

References QMetaObject::className(), IsUnresolvedSignal, QMetaObject::methodOffset(), qWarning, stringData(), and typeId().

Referenced by QQmlWatchProxy::QQmlWatchProxy(), QUntypedBindable::QUntypedBindable(), QQmlProperty::connectNotifySignal(), and notifySignal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ propertyIndex()

int QMetaProperty::propertyIndex ( ) const
Since
4.6

Returns this property's index.

Definition at line 3562 of file qmetaobject.cpp.

References QMetaObject::propertyOffset().

Referenced by QUntypedBindable::QUntypedBindable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

QVariant QMetaProperty::read ( const QObject * object) const

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
write(), reset(), isReadable()

Definition at line 3712 of file qmetaobject.cpp.

References QMetaObject::d, QMetaObject::metacall(), priv(), PropertyAccessInStaticMetaCall, QMetaObject::propertyOffset(), and QMetaObject::ReadProperty.

Referenced by QQuickPropertyChanges::actions(), QQuickDesignerSupportProperties::allPropertyNames(), allSubObjects(), QQmlContextData::findObjectId(), QtAndroidQuickViewEmbedding::getRootObjectProperty(), QQmlWatchProxy::notifyValueChanged(), propertyNameListForWritableProperties(), readObjectProperty(), readOnGadget(), and QQuickDesignerSupportProperties::readQObjectProperty().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readOnGadget()

QVariant QMetaProperty::readOnGadget ( const void * gadget) const
Since
5.5

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

Definition at line 3861 of file qmetaobject.cpp.

References QMetaObject::d, priv(), PropertyAccessInStaticMetaCall, Q_ASSERT, and read().

Referenced by VDMListDelegateDataType::value().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ relativePropertyIndex()

int QMetaProperty::relativePropertyIndex ( ) const
Since
5.14

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

Definition at line 3574 of file qmetaobject.cpp.

◆ reset()

bool QMetaProperty::reset ( QObject * object) const

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

Definition at line 3825 of file qmetaobject.cpp.

References QMetaObject::d, isResettable(), QMetaObject::metacall(), priv(), PropertyAccessInStaticMetaCall, QMetaObject::propertyOffset(), and QMetaObject::ResetProperty.

+ Here is the call graph for this function:

◆ resetOnGadget()

bool QMetaProperty::resetOnGadget ( void * gadget) const
Since
5.5

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

Definition at line 3901 of file qmetaobject.cpp.

References QMetaObject::d, priv(), PropertyAccessInStaticMetaCall, and Q_ASSERT.

+ Here is the call graph for this function:

◆ revision()

int QMetaProperty::revision ( ) const
Since
5.1

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

Definition at line 4001 of file qmetaobject.cpp.

Referenced by QMetaObjectBuilder::addProperty().

+ Here is the caller graph for this function:

◆ typeId()

int QMetaProperty::typeId ( ) const
inline
Since
6.0

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

See also
QMetaType, typeName(), metaType()

Definition at line 339 of file qmetaobject.h.

Referenced by notifySignalIndex().

+ Here is the caller graph for this function:

◆ typeName()

const char * QMetaProperty::typeName ( ) const

Returns the name of this property's type.

See also
type(), name()

Definition at line 3499 of file qmetaobject.cpp.

References QMetaType::isValid(), QMetaEnum::metaType(), and typeNameFromTypeInfo().

Referenced by QQmlVMEResolvedList::QQmlVMEResolvedList(), and QMetaObjectBuilder::addProperty().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ userType()

int QMetaProperty::userType ( ) const
inline
Since
4.2

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

Definition at line 338 of file qmetaobject.h.

◆ write() [1/2]

bool QMetaProperty::write ( QObject * object,
const QVariant & value ) const

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 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.

Note
This function internally makes a copy of value. Prefer to use the rvalue overload when possible.
See also
read(), reset(), isWritable()

Definition at line 3761 of file qmetaobject.cpp.

References isWritable(), and write().

Referenced by QtPrivate::PropertyAdaptorSlotObjectHelpers::bindingWrapper(), QtAndroidQuickViewEmbedding::setRootObjectProperty(), write(), writeOnGadget(), and writeOnGadget().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write() [2/2]

bool QMetaProperty::write ( QObject * object,
QVariant && v ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
6.6

Definition at line 3772 of file qmetaobject.cpp.

References QMetaObject::d, isEnumType(), isFlagType(), isResettable(), isWritable(), QMetaEnum::keysToValue(), QMetaEnum::keyToValue(), QMetaObject::metacall(), ok, priv(), PropertyAccessInStaticMetaCall, QMetaObject::propertyOffset(), and QMetaObject::WriteProperty.

+ Here is the call graph for this function:

◆ writeOnGadget() [1/2]

bool QMetaProperty::writeOnGadget ( void * gadget,
const QVariant & value ) const
Since
5.5

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

Definition at line 3875 of file qmetaobject.cpp.

References QMetaObject::d, priv(), PropertyAccessInStaticMetaCall, Q_ASSERT, and write().

Referenced by doWriteProperties(), doWriteProperties(), doWriteProperties(), doWriteProperty(), and VDMListDelegateDataType::setValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeOnGadget() [2/2]

bool QMetaProperty::writeOnGadget ( void * gadget,
QVariant && value ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
6.6

Definition at line 3885 of file qmetaobject.cpp.

References QMetaObject::d, priv(), PropertyAccessInStaticMetaCall, Q_ASSERT, and write().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ QMetaObject

friend struct QMetaObject
friend

Definition at line 409 of file qmetaobject.h.

◆ QMetaObjectPrivate

friend struct QMetaObjectPrivate
friend

Definition at line 410 of file qmetaobject.h.


The documentation for this class was generated from the following files: