Qt 4.8
|
The QDeclarativeProperty class abstracts accessing properties on objects created from QML. More...
#include <qdeclarativeproperty.h>
Public Types | |
enum | PropertyTypeCategory { InvalidCategory, List, Object, Normal } |
This enum specifies a category of QML property. More... | |
enum | Type { Invalid, Property, SignalProperty } |
This enum specifies a type of QML property. More... | |
Public Functions | |
bool | connectNotifySignal (QObject *dest, const char *slot) const |
Connects the property's change notifier signal to the specified slot of the dest object and returns true. More... | |
bool | connectNotifySignal (QObject *dest, int method) const |
Connects the property's change notifier signal to the specified method of the dest object and returns true. More... | |
bool | hasNotifySignal () const |
Returns true if the property has a change notifier signal, otherwise false. More... | |
int | index () const |
Return the Qt metaobject index of the property. More... | |
bool | isDesignable () const |
Returns true if the property is designable, otherwise false. More... | |
bool | isProperty () const |
Returns true if this QDeclarativeProperty represents a regular Qt property. More... | |
bool | isResettable () const |
Returns true if the property is resettable, otherwise false. More... | |
bool | isSignalProperty () const |
Returns true if this QDeclarativeProperty represents a QML signal property. More... | |
bool | isValid () const |
Returns true if the QDeclarativeProperty refers to a valid property, otherwise false. More... | |
bool | isWritable () const |
Returns true if the property is writable, otherwise false. More... | |
QMetaMethod | method () const |
Return the QMetaMethod for this property if it is a SignalProperty, otherwise returns an invalid QMetaMethod. More... | |
QString | name () const |
Return the name of this QML property. More... | |
bool | needsNotifySignal () const |
Returns true if the property needs a change notifier signal for bindings to remain upto date, false otherwise. More... | |
QObject * | object () const |
Returns the QDeclarativeProperty's QObject. More... | |
QDeclarativeProperty & | operator= (const QDeclarativeProperty &) |
Assign other to this QDeclarativeProperty. More... | |
bool | operator== (const QDeclarativeProperty &) const |
Returns true if other and this QDeclarativeProperty represent the same property. More... | |
QMetaProperty | property () const |
Returns the Qt property associated with this QML property. More... | |
int | propertyType () const |
Returns the QVariant type of the property, or QVariant::Invalid if the property has no QVariant type. More... | |
PropertyTypeCategory | propertyTypeCategory () const |
Returns the property category. More... | |
const char * | propertyTypeName () const |
Returns the type name of the property, or 0 if the property has no type name. More... | |
QDeclarativeProperty () | |
Create an invalid QDeclarativeProperty. More... | |
QDeclarativeProperty (QObject *) | |
Creates a QDeclarativeProperty for the default property of obj. More... | |
QDeclarativeProperty (QObject *, QDeclarativeContext *) | |
Creates a QDeclarativeProperty for the default property of obj using the context ctxt. More... | |
QDeclarativeProperty (QObject *, QDeclarativeEngine *) | |
Creates a QDeclarativeProperty for the default property of obj using the environment for instantiating QML components that is provided by engine. More... | |
QDeclarativeProperty (QObject *, const QString &) | |
Creates a QDeclarativeProperty for the property name of obj. More... | |
QDeclarativeProperty (QObject *, const QString &, QDeclarativeContext *) | |
Creates a QDeclarativeProperty for the property name of obj using the context ctxt. More... | |
QDeclarativeProperty (QObject *, const QString &, QDeclarativeEngine *) | |
Creates a QDeclarativeProperty for the property name of obj using the environment for instantiating QML components that is provided by engine. More... | |
QDeclarativeProperty (const QDeclarativeProperty &) | |
Create a copy of other. More... | |
QVariant | read () const |
Returns the property value. More... | |
bool | reset () const |
Resets the property and returns true if the property is resettable. More... | |
Type | type () const |
Returns the type of the property. More... | |
bool | write (const QVariant &) const |
Sets the property value to value and returns true. More... | |
~QDeclarativeProperty () | |
Static Public Functions | |
static QVariant | read (QObject *, const QString &) |
Return the name property value of object. More... | |
static QVariant | read (QObject *, const QString &, QDeclarativeContext *) |
Return the name property value of object using the context ctxt. More... | |
static QVariant | read (QObject *, const QString &, QDeclarativeEngine *) |
Return the name property value of object using the environment for instantiating QML components that is provided by engine. More... | |
static bool | write (QObject *, const QString &, const QVariant &) |
Writes value to the name property of object. More... | |
static bool | write (QObject *, const QString &, const QVariant &, QDeclarativeContext *) |
Writes value to the name property of object using the context ctxt. More... | |
static bool | write (QObject *, const QString &, const QVariant &, QDeclarativeEngine *) |
Writes value to the name property of object using the environment for instantiating QML components that is provided by engine. More... | |
Properties | |
QDeclarativePropertyPrivate * | d |
Friends | |
class | QDeclarativePropertyPrivate |
The QDeclarativeProperty class abstracts accessing properties on objects created from QML.
As QML uses Qt's meta-type system all of the existing QMetaObject classes can be used to introspect and interact with objects created by QML. However, some of the new features provided by QML - such as type safety and attached properties - are most easily used through the QDeclarativeProperty class that simplifies some of their natural complexity.
Unlike QMetaProperty which represents a property on a class type, QDeclarativeProperty encapsulates a property on a specific object instance. To read a property's value, programmers create a QDeclarativeProperty instance and call the read() method. Likewise to write a property value the write() method is used.
For example, for the following QML code:
The Text object's properties could be accessed using QDeclarativeProperty, like this:
Definition at line 59 of file qdeclarativeproperty.h.
This enum specifies a category of QML property.
Enumerator | |
---|---|
InvalidCategory | |
List | |
Object | |
Normal |
Definition at line 62 of file qdeclarativeproperty.h.
This enum specifies a type of QML property.
Enumerator | |
---|---|
Invalid | |
Property | |
SignalProperty |
Definition at line 69 of file qdeclarativeproperty.h.
QDeclarativeProperty::QDeclarativeProperty | ( | ) |
QDeclarativeProperty::~QDeclarativeProperty | ( | ) |
Definition at line 117 of file qdeclarativeproperty.cpp.
QDeclarativeProperty::QDeclarativeProperty | ( | QObject * | obj | ) |
Creates a QDeclarativeProperty for the default property of obj.
If there is no default property, an invalid QDeclarativeProperty will be created.
Definition at line 128 of file qdeclarativeproperty.cpp.
QDeclarativeProperty::QDeclarativeProperty | ( | QObject * | obj, |
QDeclarativeContext * | ctxt | ||
) |
Creates a QDeclarativeProperty for the default property of obj using the context ctxt.
If there is no default property, an invalid QDeclarativeProperty will be created.
Definition at line 140 of file qdeclarativeproperty.cpp.
QDeclarativeProperty::QDeclarativeProperty | ( | QObject * | obj, |
QDeclarativeEngine * | engine | ||
) |
Creates a QDeclarativeProperty for the default property of obj using the environment for instantiating QML components that is provided by engine.
If there is no default property, an invalid QDeclarativeProperty will be created.
Definition at line 154 of file qdeclarativeproperty.cpp.
Creates a QDeclarativeProperty for the property name of obj.
Definition at line 179 of file qdeclarativeproperty.cpp.
QDeclarativeProperty::QDeclarativeProperty | ( | QObject * | obj, |
const QString & | name, | ||
QDeclarativeContext * | ctxt | ||
) |
Creates a QDeclarativeProperty for the property name of obj using the context ctxt.
Creating a QDeclarativeProperty without a context will render some properties - like attached properties - inaccessible.
Definition at line 193 of file qdeclarativeproperty.cpp.
QDeclarativeProperty::QDeclarativeProperty | ( | QObject * | obj, |
const QString & | name, | ||
QDeclarativeEngine * | engine | ||
) |
Creates a QDeclarativeProperty for the property name of obj using the environment for instantiating QML components that is provided by engine.
Definition at line 207 of file qdeclarativeproperty.cpp.
QDeclarativeProperty::QDeclarativeProperty | ( | const QDeclarativeProperty & | other | ) |
bool QDeclarativeProperty::connectNotifySignal | ( | QObject * | dest, |
const char * | slot | ||
) | const |
Connects the property's change notifier signal to the specified slot of the dest object and returns true.
Returns false if this metaproperty does not represent a regular Qt property or if it has no change notifier signal, or if the dest object does not have the specified slot.
Definition at line 1409 of file qdeclarativeproperty.cpp.
bool QDeclarativeProperty::connectNotifySignal | ( | QObject * | dest, |
int | method | ||
) | const |
Connects the property's change notifier signal to the specified method of the dest object and returns true.
Returns false if this metaproperty does not represent a regular Qt property or if it has no change notifier signal, or if the dest object does not have the specified method.
Definition at line 1388 of file qdeclarativeproperty.cpp.
bool QDeclarativeProperty::hasNotifySignal | ( | ) | const |
Returns true if the property has a change notifier signal, otherwise false.
Definition at line 1360 of file qdeclarativeproperty.cpp.
int QDeclarativeProperty::index | ( | ) | const |
Return the Qt metaobject index of the property.
Definition at line 1426 of file qdeclarativeproperty.cpp.
Referenced by QDeclarativePropertyPrivate::binding(), QDeclarativePropertyPrivate::setBinding(), QDeclarativePropertyPrivate::setBindingNoEnable(), QDeclarativePropertyPrivate::setSignalExpression(), and QDeclarativePropertyPrivate::signalExpression().
bool QDeclarativeProperty::isDesignable | ( | ) | const |
Returns true if the property is designable, otherwise false.
Definition at line 543 of file qdeclarativeproperty.cpp.
bool QDeclarativeProperty::isProperty | ( | ) | const |
Returns true if this QDeclarativeProperty represents a regular Qt property.
Definition at line 486 of file qdeclarativeproperty.cpp.
Referenced by QDeclarativePropertyPrivate::binding(), QDeclarativeEngineDebugService::setBinding(), and QDeclarativePropertyPrivate::setBinding().
bool QDeclarativeProperty::isResettable | ( | ) | const |
Returns true if the property is resettable, otherwise false.
Definition at line 556 of file qdeclarativeproperty.cpp.
Referenced by reset(), and QDeclarativeEngineDebugService::resetBinding().
bool QDeclarativeProperty::isSignalProperty | ( | ) | const |
Returns true if this QDeclarativeProperty represents a QML signal property.
Definition at line 494 of file qdeclarativeproperty.cpp.
bool QDeclarativeProperty::isValid | ( | ) | const |
Returns true if the QDeclarativeProperty refers to a valid property, otherwise false.
Definition at line 570 of file qdeclarativeproperty.cpp.
Referenced by QDeclarativePropertyChanges::actions(), QDeclarativeConnections::connectSignals(), QDeclarativeAbstractAnimationPrivate::createProperty(), QDeclarativePropertyChangesPrivate::property(), QDeclarativeAction::QDeclarativeAction(), QDeclarativeProperty(), QDeclarativeEngineDebugService::setBinding(), QDeclarativePropertyAction::transition(), and QDeclarativePropertyAnimation::transition().
bool QDeclarativeProperty::isWritable | ( | ) | const |
Returns true if the property is writable, otherwise false.
Definition at line 524 of file qdeclarativeproperty.cpp.
Referenced by QDeclarativeAbstractAnimationPrivate::createProperty(), QDeclarativePropertyChangesPrivate::property(), and QDeclarativePropertyPrivate::write().
QMetaMethod QDeclarativeProperty::method | ( | ) | const |
Return the QMetaMethod for this property if it is a SignalProperty, otherwise returns an invalid QMetaMethod.
Definition at line 632 of file qdeclarativeproperty.cpp.
Referenced by connectNotifySignal(), QDeclarativeConnections::connectSignals(), QDeclarativePropertyPrivate::findSignalByName(), QDeclarativePropertyPrivate::initProperty(), and QDeclarativePropertyPrivate::setSignalExpression().
QString QDeclarativeProperty::name | ( | ) | const |
Return the name of this QML property.
Definition at line 580 of file qdeclarativeproperty.cpp.
Referenced by QDeclarativeState::apply(), qHash(), QDeclarativeState::removeEntryFromRevertList(), QDeclarativeTransitionManager::transition(), QDeclarativePropertyAction::transition(), and QDeclarativePropertyAnimation::transition().
bool QDeclarativeProperty::needsNotifySignal | ( | ) | const |
Returns true if the property needs a change notifier signal for bindings to remain upto date, false otherwise.
Some properties, such as attached properties or those whose value never changes, do not require a change notifier.
Definition at line 1375 of file qdeclarativeproperty.cpp.
QObject * QDeclarativeProperty::object | ( | ) | const |
Returns the QDeclarativeProperty's QObject.
Definition at line 502 of file qdeclarativeproperty.cpp.
Referenced by QDeclarativeState::apply(), QDeclarativePropertyPrivate::findAliasTarget(), qHash(), QDeclarativeState::removeAllEntriesFromRevertList(), QDeclarativeState::removeEntryFromRevertList(), QDeclarativePropertyPrivate::restore(), QDeclarativeTransitionManager::transition(), QDeclarativePropertyAction::transition(), and QDeclarativePropertyAnimation::transition().
QDeclarativeProperty & QDeclarativeProperty::operator= | ( | const QDeclarativeProperty & | other | ) |
bool QDeclarativeProperty::operator== | ( | const QDeclarativeProperty & | other | ) | const |
Returns true if other and this QDeclarativeProperty represent the same property.
Definition at line 425 of file qdeclarativeproperty.cpp.
QMetaProperty QDeclarativeProperty::property | ( | ) | const |
Returns the Qt property associated with this QML property.
Definition at line 618 of file qdeclarativeproperty.cpp.
Referenced by flush_vme_signal(), QDeclarativePropertyPrivate::initProperty(), and needsNotifySignal().
int QDeclarativeProperty::propertyType | ( | ) | const |
Returns the QVariant type of the property, or QVariant::Invalid if the property has no QVariant type.
Definition at line 440 of file qdeclarativeproperty.cpp.
Referenced by QDeclarativePropertyPrivate::propertyTypeCategory(), QDeclarativeAnimationPropertyUpdater::setValue(), QDeclarativePropertyAction::transition(), QDeclarativePropertyAnimation::transition(), and QDeclarativePropertyPrivate::write().
QDeclarativeProperty::PropertyTypeCategory QDeclarativeProperty::propertyTypeCategory | ( | ) | const |
Returns the property category.
Definition at line 364 of file qdeclarativeproperty.cpp.
const char * QDeclarativeProperty::propertyTypeName | ( | ) | const |
Returns the type name of the property, or 0 if the property has no type name.
Definition at line 397 of file qdeclarativeproperty.cpp.
QVariant QDeclarativeProperty::read | ( | ) | const |
Returns the property value.
Definition at line 921 of file qdeclarativeproperty.cpp.
Referenced by QDeclarativePropertyChanges::actions(), QDeclarativeParentChange::actions(), QDeclarativePropertyChanges::changeExpression(), QDeclarativePropertyChanges::changeValue(), QSmoothedAnimation::init(), QDeclarativeAction::QDeclarativeAction(), read(), QDeclarativeEngineDebugService::resetBinding(), QDeclarativeAnimationPropertyUpdater::setValue(), and QDeclarativeTransitionManager::transition().
Return the name property value of object.
This method is equivalent to:
Definition at line 947 of file qdeclarativeproperty.cpp.
|
static |
Return the name property value of object using the context ctxt.
This method is equivalent to:
Definition at line 963 of file qdeclarativeproperty.cpp.
|
static |
Return the name property value of object using the environment for instantiating QML components that is provided by engine.
This method is equivalent to:
Definition at line 980 of file qdeclarativeproperty.cpp.
bool QDeclarativeProperty::reset | ( | ) | const |
Resets the property and returns true if the property is resettable.
If the property is not resettable, nothing happens and false is returned.
Definition at line 1334 of file qdeclarativeproperty.cpp.
QDeclarativeProperty::Type QDeclarativeProperty::type | ( | ) | const |
Returns the type of the property.
Definition at line 478 of file qdeclarativeproperty.cpp.
Referenced by connectNotifySignal(), QDeclarativeConnections::connectSignals(), QDeclarativePropertyChangesPrivate::decode(), hasNotifySignal(), isDesignable(), isProperty(), isResettable(), isSignalProperty(), isValid(), method(), name(), needsNotifySignal(), property(), QDeclarativePropertyChangesPrivate::property(), QDeclarativePropertyPrivate::propertyType(), QDeclarativePropertyPrivate::propertyTypeCategory(), propertyTypeName(), QDeclarativePropertyPrivate::rawMetaObjectForType(), read(), QDeclarativePropertyPrivate::setSignalExpression(), QDeclarativePropertyPrivate::signalExpression(), QDeclarativePropertyPrivate::write(), and QDeclarativePropertyPrivate::writeValueProperty().
bool QDeclarativeProperty::write | ( | const QVariant & | value | ) | const |
Sets the property value to value and returns true.
Returns false if the property can't be set because the value is the wrong type, for example.
Definition at line 1272 of file qdeclarativeproperty.cpp.
Referenced by QDeclarativeState::addEntriesToRevertList(), QDeclarativeTransitionManager::complete(), QDeclarativeBind::eval(), QDeclarativeState::removeAllEntriesFromRevertList(), QDeclarativeState::removeEntryFromRevertList(), QDeclarativeTransitionManager::transition(), write(), and QDeclarativePropertyPrivate::writeValueProperty().
|
static |
Writes value to the name property of object.
This method is equivalent to:
Definition at line 1286 of file qdeclarativeproperty.cpp.
|
static |
Writes value to the name property of object using the context ctxt.
This method is equivalent to:
Definition at line 1302 of file qdeclarativeproperty.cpp.
|
static |
Writes value to the name property of object using the environment for instantiating QML components that is provided by engine.
This method is equivalent to:
Definition at line 1322 of file qdeclarativeproperty.cpp.
|
friend |
Definition at line 129 of file qdeclarativeproperty.h.
Referenced by QDeclarativePropertyPrivate::restore().
|
private |
Definition at line 130 of file qdeclarativeproperty.h.
Referenced by QDeclarativePropertyPrivate::binding(), QDeclarativePropertyPrivate::bindingIndex(), connectNotifySignal(), hasNotifySignal(), index(), isDesignable(), isResettable(), isValid(), isWritable(), method(), name(), object(), operator=(), operator==(), property(), propertyType(), propertyTypeCategory(), propertyTypeName(), QDeclarativeProperty(), read(), reset(), QDeclarativePropertyPrivate::restore(), QDeclarativePropertyPrivate::setBinding(), QDeclarativePropertyPrivate::setSignalExpression(), QDeclarativePropertyPrivate::signalExpression(), type(), QDeclarativePropertyPrivate::valueTypeCoreIndex(), QDeclarativePropertyPrivate::write(), and ~QDeclarativeProperty().