CopperSpice API  1.7.4
QMetaProperty Class Reference

The QMetaProperty class provides meta data about a property. More...

Public Methods

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 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 QStringname () const
 
QMetaMethod notifySignal () const
 
int notifySignalIndex () const
 
int propertyIndex () const
 
QVariant read (const QObject *obj) const
 
template<class T >
read (const QObject *obj) const
 
bool reset (QObject *obj) const
 
int revision () const
 
void setConstant ()
 
void setFinal ()
 
template<class T >
void setNotifyMethod (T method)
 
template<class T >
void setResetMethod (void (T::*method)())
 
void setRevision (int value)
 
void setTypeName (const QString &typeName)
 
QVariant::Type type () const
 
const QStringtypeName () const
 
uint userType () const
 
bool write (QObject *object, const QVariant &value) const
 

Detailed Description

The QMetaProperty class provides meta data about a property. The property meta data is retrieved from the meta object for a given class. Refer to QMetaObject::property() and QMetaObject::propertyCount() for more information.

Property Meta Data

A property has a name and a data type as well as various other optional attributes. These include writable, designable, scriptable, and stored. The value of a property is set or retrieved using read(), write(), and reset(). The property can also be changed using QObject::setProperty() and QObject::property().

If the data type for the property is an enumeration the isEnumType() method will return true. If the property is a flag isEnumType() and isFlagType() both return true. A flag is a data type where values can be combined using the OR operator. For an enum or a flag the meta data for the data type is available by calling enumerator().

Copying and Assignment

QMetaProperty objects can be copied. Each copy will refer to the same underlying property meta data.

See also
QMetaObject, QMetaEnum, QMetaMethod, Property System

Method Documentation

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()
bool QMetaProperty::hasNotifySignal ( ) const

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

See also
notifySignal()
bool QMetaProperty::isConstant ( ) const

Returns true if the property is constant, otherwise returns false. A property is constant if the property's CONSTANT attribute is set.

bool QMetaProperty::isDesignable ( const QObject object = nullptr) const

Returns true if this property is designable for the given object, otherwise returns false. If the given object is a nullptr and the Designable property exists, then true is returned.

See also
isScriptable(), isStored()
bool QMetaProperty::isEnumType ( ) const

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

See also
enumerator(), isFlagType()
bool QMetaProperty::isFinal ( ) const

Returns true if the property is final, otherwise returns false. A property is final if the property's FINAL attribute is set.

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 also considered an enum type.

See also
isEnumType(), enumerator(), QMetaEnum::isFlag()
bool QMetaProperty::isReadable ( ) const

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

See also
isWritable(), read(), isValid()
bool QMetaProperty::isResettable ( ) const

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

See also
reset()
bool QMetaProperty::isScriptable ( const QObject object = nullptr) const

Returns true if this property is scriptable for the given object, otherwise returns false. If the given object is a nullptr and the Scriptable property exists, then true is returned.

See also
isDesignable(), isStored()
bool QMetaProperty::isStored ( const QObject object = nullptr) const

Returns true if this property is stored for the given object, otherwise returns false. If the given object is a nullptr and the Stored property exists, then true is returned.

See also
isDesignable(), isScriptable()
bool QMetaProperty::isUser ( const QObject object = nullptr) const

Returns true if this property is the user property for the given object, otherwise returns false. If the given object is a nullptr and the User property exists, then true is returned.

See also
QMetaObject::userProperty(), isDesignable(), isScriptable()
bool QMetaProperty::isValid ( ) const

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

See also
isReadable()
bool QMetaProperty::isWritable ( ) const

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

See also
isReadable(), write()
const QString & QMetaProperty::name ( ) const

Returns the name of this property.

See also
type(), typeName()
QMetaMethod QMetaProperty::notifySignal ( ) const

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

See also
hasNotifySignal()
int QMetaProperty::notifySignalIndex ( ) const

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

See also
hasNotifySignal()
int QMetaProperty::propertyIndex ( ) const

Returns the index of this property which indicates the position in the QMetaObject.

QVariant QMetaProperty::read ( const QObject obj) const

Reads the property's value from the given obj. Returns the property value as a QVariant if valid, otherwise returns a QVariant which is invalid.

See also
write(), reset(), isReadable()
template<class T >
T QMetaProperty::read ( const QObject obj) const

Reads the property's value from the given obj. Returns the property value if valid, otherwise returns a default constructed T.

bool QMetaProperty::reset ( QObject obj) const

Resets the property for the given obj with a reset method. Returns true if the reset was successful, otherwise returns false.

See also
read(), write()
int QMetaProperty::revision ( ) const

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

void QMetaProperty::setConstant ( )

Sets this property to constant which means the value of the property can not change.

void QMetaProperty::setFinal ( )

Sets this property to final which means the property can not be overridden in a child class.

template<class T >
void QMetaProperty::setNotifyMethod ( method)

Sets the notify method of this property to method.

template<class T >
void QMetaProperty::setResetMethod ( void (T::*)()  method)

Sets the reset method of this property to method.

void QMetaProperty::setRevision ( int  value)

Sets the revision of this property to the given value.

void QMetaProperty::setTypeName ( const QString typeName)

Sets the type name of this property to typeName.

QVariant::Type QMetaProperty::type ( ) const

Returns this property's data type. The return value is one of the values of the QVariant::Type enumeration.

See also
userType(), typeName(), name()
const QString & QMetaProperty::typeName ( ) const

Returns the name of this property's type.

See also
type(), name()
uint QMetaProperty::userType ( ) const

Returns this property's user type. The return value is one of the values that are registered with QVariant or QVariant::Invalid if the type is not registered.

See also
type(), typeName()
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.

See also
read(), reset(), isWritable()