CopperSpice API  1.7.2
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. Property meta data is obtained from an object's meta object. Refer to QMetaObject::property() and QMetaObject::propertyCount() for details.

Property Meta Data

A property has a name() and a type(), as well as various attributes that specify its behavior: isReadable(), isWritable(), isDesignable(), isScriptable(), and isStored().

If the property is an enumeration, isEnumType() returns true; if the property is an enumeration that is also a flag (i.e. its values can be combined using the OR operator), isEnumType() and isFlagType() both return true. The enumerator for these types is available from enumerator().

The property's values are set and retrieved with read(), write(), and reset(). They can also be changed through QObject's set and get functions. Refer to QObject::setProperty() and QObject::property() for details.

Copying and Assignment

QMetaProperty objects can be copied by value. However, each copy will refer to the same underlying property meta data.

See also
QMetaObject, QMetaEnum, QMetaMethod, the 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 object is null false 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 implicitly also 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 the property is scriptable for the given object otherwise returns false. If object is nullptr the method returns false.

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

Returns true if the property is stored for object otherwise returns false. If object is nullptr the method returns false.

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

Returns true if this property is designated as the USER property. The USER property is defined as the one which the user can edit. If object is null the function returns false.

For example, the text property is the USER editable property of a QLineEdit.

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 worked, otherwise returns false. Reset methods are optional only a few properties support them.

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 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 QMetaType, or 0 if the type is not registered.

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