Qt 4.8
Public Types | Public Functions | Static Public Functions | Properties | Friends | List of all members
QDeclarativeProperty Class Reference

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...
 
QObjectobject () const
 Returns the QDeclarativeProperty's QObject. More...
 
QDeclarativePropertyoperator= (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

QDeclarativePropertyPrivated
 

Friends

class QDeclarativePropertyPrivate
 

Detailed Description

The QDeclarativeProperty class abstracts accessing properties on objects created from QML.

Since
4.7

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:

// MyItem.qml
import QtQuick 1.0
Text { text: "A bit of text" }

The Text object's properties could be accessed using QDeclarativeProperty, like this:

#include <QDeclarativeProperty>
#include <QGraphicsObject>
...
QDeclarativeView view(QUrl::fromLocalFile("MyItem.qml"));
QDeclarativeProperty property(view.rootObject(), "font.pixelSize");
qWarning() << "Current pixel size:" << property.read().toInt();
property.write(24);
qWarning() << "Pixel size should now be 24:" << property.read().toInt();

Definition at line 59 of file qdeclarativeproperty.h.

Enumerations

◆ PropertyTypeCategory

This enum specifies a category of QML property.

  • InvalidCategory The property is invalid, or is a signal property.
  • List The property is a QDeclarativeListProperty list property
  • Object The property is a QObject derived type pointer
  • Normal The property is a normal value property.
Enumerator
InvalidCategory 
List 
Object 
Normal 

Definition at line 62 of file qdeclarativeproperty.h.

◆ Type

This enum specifies a type of QML property.

  • Invalid The property is invalid.
  • Property The property is a regular Qt property.
  • SignalProperty The property is a signal property.
Enumerator
Invalid 
Property 
SignalProperty 

Definition at line 69 of file qdeclarativeproperty.h.

Constructors and Destructors

◆ QDeclarativeProperty() [1/8]

QDeclarativeProperty::QDeclarativeProperty ( )

Create an invalid QDeclarativeProperty.

Definition at line 111 of file qdeclarativeproperty.cpp.

112 : d(0)
113 {
114 }
QDeclarativePropertyPrivate * d

◆ ~QDeclarativeProperty()

QDeclarativeProperty::~QDeclarativeProperty ( )
Warning
This function is not part of the public interface.

Definition at line 117 of file qdeclarativeproperty.cpp.

118 {
119  if (d)
120  d->release();
121  d = 0;
122 }
QDeclarativePropertyPrivate * d

◆ QDeclarativeProperty() [2/8]

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.

130 {
131  d->initDefault(obj);
132 }
void initDefault(QObject *obj)
Initialize from the default property of obj.
QDeclarativePropertyPrivate * d

◆ QDeclarativeProperty() [3/8]

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.

142 {
143  d->context = ctxt?QDeclarativeContextData::get(ctxt):0;
144  d->engine = ctxt?ctxt->engine():0;
145  d->initDefault(obj);
146 }
QDeclarativeContextData * context
void initDefault(QObject *obj)
Initialize from the default property of obj.
QDeclarativePropertyPrivate * d
QDeclarativeEngine * engine() const
Return the context&#39;s QDeclarativeEngine, or 0 if the context has no QDeclarativeEngine or the QDeclar...
static QDeclarativeContextData * get(QDeclarativeContext *context)

◆ QDeclarativeProperty() [4/8]

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.

156 {
157  d->context = 0;
158  d->engine = engine;
159  d->initDefault(obj);
160 }
QDeclarativeContextData * context
void initDefault(QObject *obj)
Initialize from the default property of obj.
QDeclarativePropertyPrivate * d

◆ QDeclarativeProperty() [5/8]

QDeclarativeProperty::QDeclarativeProperty ( QObject obj,
const QString name 
)

Creates a QDeclarativeProperty for the property name of obj.

Definition at line 179 of file qdeclarativeproperty.cpp.

181 {
182  d->initProperty(obj, name);
183  if (!isValid()) d->object = 0;
184 }
bool isValid() const
Returns true if the QDeclarativeProperty refers to a valid property, otherwise false.
void initProperty(QObject *obj, const QString &name)
QDeclarativePropertyPrivate * d
QDeclarativeGuard< QObject > object

◆ QDeclarativeProperty() [6/8]

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.

195 {
196  d->context = ctxt?QDeclarativeContextData::get(ctxt):0;
197  d->engine = ctxt?ctxt->engine():0;
198  d->initProperty(obj, name);
199  if (!isValid()) { d->object = 0; d->context = 0; d->engine = 0; }
200 }
bool isValid() const
Returns true if the QDeclarativeProperty refers to a valid property, otherwise false.
QDeclarativeContextData * context
void initProperty(QObject *obj, const QString &name)
QDeclarativePropertyPrivate * d
QDeclarativeEngine * engine() const
Return the context&#39;s QDeclarativeEngine, or 0 if the context has no QDeclarativeEngine or the QDeclar...
QDeclarativeGuard< QObject > object
static QDeclarativeContextData * get(QDeclarativeContext *context)

◆ QDeclarativeProperty() [7/8]

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.

209 {
210  d->context = 0;
211  d->engine = engine;
212  d->initProperty(obj, name);
213  if (!isValid()) { d->object = 0; d->context = 0; d->engine = 0; }
214 }
bool isValid() const
Returns true if the QDeclarativeProperty refers to a valid property, otherwise false.
QDeclarativeContextData * context
void initProperty(QObject *obj, const QString &name)
QDeclarativePropertyPrivate * d
QDeclarativeGuard< QObject > object

◆ QDeclarativeProperty() [8/8]

QDeclarativeProperty::QDeclarativeProperty ( const QDeclarativeProperty other)

Create a copy of other.

Definition at line 327 of file qdeclarativeproperty.cpp.

328 {
329  d = other.d;
330  if (d)
331  d->addref();
332 }
QDeclarativePropertyPrivate * d

Functions

◆ connectNotifySignal() [1/2]

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.

1410 {
1411  if (!(type() & Property) || !d->object)
1412  return false;
1413 
1415  if (prop.hasNotifySignal()) {
1416  QByteArray signal(QByteArray("2") + prop.notifySignal().signature());
1417  return QObject::connect(d->object, signal.constData(), dest, slot);
1418  } else {
1419  return false;
1420  }
1421 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
Type type() const
Returns the type of the property.
QDeclarativePropertyCache::Data core
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
QMetaMethod notifySignal() const
Returns the QMetaMethod instance of the property change notifying signal if one was specified...
QDeclarativePropertyPrivate * d
QDeclarativeGuard< QObject > object
The QMetaProperty class provides meta-data about a property.
Definition: qmetaobject.h:176
const char * signature() const
Returns the signature of this method (e.g., setValue(double)).
bool hasNotifySignal() const
Returns true if this property has a corresponding change notify signal; otherwise returns false...
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.

◆ connectNotifySignal() [2/2]

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.

1389 {
1390  if (!(type() & Property) || !d->object)
1391  return false;
1392 
1394  if (prop.hasNotifySignal()) {
1396  } else {
1397  return false;
1398  }
1399 }
int notifySignalIndex() const
Returns the index of the property change notifying signal if one was specified, otherwise returns -1...
static bool connect(QObject *sender, int signal_index, const QObject *receiver, int method_index, int type=0, int *types=0)
Connect sender signal_index to receiver method_index with the specified type and types.
Type type() const
Returns the type of the property.
QDeclarativePropertyCache::Data core
QMetaMethod method() const
Return the QMetaMethod for this property if it is a SignalProperty, otherwise returns an invalid QMet...
QDeclarativePropertyPrivate * d
QDeclarativeGuard< QObject > object
The QMetaProperty class provides meta-data about a property.
Definition: qmetaobject.h:176
bool hasNotifySignal() const
Returns true if this property has a corresponding change notify signal; otherwise returns false...
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.

◆ hasNotifySignal()

bool QDeclarativeProperty::hasNotifySignal ( ) const

Returns true if the property has a change notifier signal, otherwise false.

Definition at line 1360 of file qdeclarativeproperty.cpp.

1361 {
1362  if (type() & Property && d->object) {
1364  }
1365  return false;
1366 }
Type type() const
Returns the type of the property.
QDeclarativePropertyCache::Data core
QDeclarativePropertyPrivate * d
QDeclarativeGuard< QObject > object
bool hasNotifySignal() const
Returns true if this property has a corresponding change notify signal; otherwise returns false...
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.

◆ index()

int QDeclarativeProperty::index ( ) const

◆ isDesignable()

bool QDeclarativeProperty::isDesignable ( ) const

Returns true if the property is designable, otherwise false.

Definition at line 543 of file qdeclarativeproperty.cpp.

544 {
545  if (!d)
546  return false;
547  if (type() & Property && d->core.isValid() && d->object)
549  else
550  return false;
551 }
Type type() const
Returns the type of the property.
QDeclarativePropertyCache::Data core
QDeclarativePropertyPrivate * d
bool isDesignable(const QObject *obj=0) const
Returns true if this property is designable for the given object; otherwise returns false...
QDeclarativeGuard< QObject > object
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.

◆ isProperty()

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

487 {
488  return type() & Property;
489 }
Type type() const
Returns the type of the property.

◆ isResettable()

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

557 {
558  if (!d)
559  return false;
560  if (type() & Property && d->core.isValid() && d->object)
562  else
563  return false;
564 }
Type type() const
Returns the type of the property.
QDeclarativePropertyCache::Data core
QDeclarativePropertyPrivate * d
QDeclarativeGuard< QObject > object

◆ isSignalProperty()

bool QDeclarativeProperty::isSignalProperty ( ) const

Returns true if this QDeclarativeProperty represents a QML signal property.

Definition at line 494 of file qdeclarativeproperty.cpp.

495 {
496  return type() & SignalProperty;
497 }
Type type() const
Returns the type of the property.

◆ isValid()

bool QDeclarativeProperty::isValid ( ) const

◆ isWritable()

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

525 {
526  if (!d)
527  return false;
528  if (!d->object)
529  return false;
531  return true;
532  else if (d->core.flags & QDeclarativePropertyCache::Data::IsFunction) //signal handler
533  return false;
534  else if (d->core.isValid()) //normal property
536  else
537  return false;
538 }
QDeclarativePropertyCache::Data core
QDeclarativePropertyPrivate * d
QDeclarativeGuard< QObject > object

◆ method()

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

633 {
634  if (!d)
635  return QMetaMethod();
636  if (type() & SignalProperty && d->object)
637  return d->object->metaObject()->method(d->core.coreIndex);
638  else
639  return QMetaMethod();
640 }
Type type() const
Returns the type of the property.
QDeclarativePropertyCache::Data core
QDeclarativePropertyPrivate * d
QDeclarativeGuard< QObject > object
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ name()

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

581 {
582  if (!d)
583  return QString();
584  if (!d->isNameCached) {
585  // ###
586  if (!d->object) {
587  } else if (d->isValueType()) {
588  QString rv = d->core.name(d->object) + QLatin1Char('.');
589 
591  QDeclarativeValueType *valueType = 0;
592  if (ep) valueType = ep->valueTypes[d->core.propType];
594  Q_ASSERT(valueType);
595 
597 
598  if (!ep) delete valueType;
599 
600  d->nameCache = rv;
601  } else if (type() & SignalProperty) {
602  QString name = QLatin1String("on") + d->core.name(d->object);
603  name[2] = name.at(2).toUpper();
604  d->nameCache = name;
605  } else {
606  d->nameCache = d->core.name(d->object);
607  }
608  d->isNameCached = true;
609  }
610 
611  return d->nameCache;
612 }
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
static QDeclarativeValueType * valueType(int)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
Type type() const
Returns the type of the property.
QDeclarativePropertyCache::Data core
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
QChar toUpper() const
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
Definition: qchar.cpp:1287
const char * name() const
Returns this property&#39;s name.
QDeclarativeValueTypeFactory valueTypes
QDeclarativePropertyPrivate * d
QDeclarativeGuard< QObject > object
QString name() const
Return the name of this QML property.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.
QDeclarativePropertyCache::ValueTypeData valueType

◆ needsNotifySignal()

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.

1376 {
1377  return type() & Property && !property().isConstant();
1378 }
Type type() const
Returns the type of the property.
QMetaProperty property() const
Returns the Qt property associated with this QML property.
bool isConstant() const

◆ object()

QObject * QDeclarativeProperty::object ( ) const

◆ operator=()

QDeclarativeProperty & QDeclarativeProperty::operator= ( const QDeclarativeProperty other)

Assign other to this QDeclarativeProperty.

Definition at line 510 of file qdeclarativeproperty.cpp.

511 {
512  if (d)
513  d->release();
514  d = other.d;
515  if (d)
516  d->addref();
517 
518  return *this;
519 }
QDeclarativePropertyPrivate * d

◆ operator==()

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.

426 {
427  if (!d || !other.d)
428  return false;
429  // category is intentially omitted here as it is generated
430  // from the other members
431  return d->object == other.d->object &&
432  d->core == other.d->core &&
433  d->valueType == other.d->valueType;
434 }
QDeclarativePropertyCache::Data core
QDeclarativePropertyPrivate * d
QDeclarativeGuard< QObject > object
QDeclarativePropertyCache::ValueTypeData valueType

◆ property()

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

619 {
620  if (!d)
621  return QMetaProperty();
622  if (type() & Property && d->core.isValid() && d->object)
623  return d->object->metaObject()->property(d->core.coreIndex);
624  else
625  return QMetaProperty();
626 }
Type type() const
Returns the type of the property.
QDeclarativePropertyCache::Data core
QDeclarativePropertyPrivate * d
QDeclarativeGuard< QObject > object
The QMetaProperty class provides meta-data about a property.
Definition: qmetaobject.h:176
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.

◆ propertyType()

int QDeclarativeProperty::propertyType ( ) const

◆ propertyTypeCategory()

QDeclarativeProperty::PropertyTypeCategory QDeclarativeProperty::propertyTypeCategory ( ) const

Returns the property category.

Definition at line 364 of file qdeclarativeproperty.cpp.

365 {
366  return d ? d->propertyTypeCategory() : InvalidCategory;
367 }
QDeclarativeProperty::PropertyTypeCategory propertyTypeCategory() const
QDeclarativePropertyPrivate * d

◆ propertyTypeName()

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.

398 {
399  if (!d)
400  return 0;
401  if (d->isValueType()) {
402 
404  QDeclarativeValueType *valueType = 0;
405  if (ep) valueType = ep->valueTypes[d->core.propType];
407  Q_ASSERT(valueType);
408 
409  const char *rv = valueType->metaObject()->property(d->valueType.valueTypeCoreIdx).typeName();
410 
411  if (!ep) delete valueType;
412 
413  return rv;
414  } else if (d->object && type() & Property && d->core.isValid()) {
416  } else {
417  return 0;
418  }
419 }
static QDeclarativeValueType * valueType(int)
Type type() const
Returns the type of the property.
QDeclarativePropertyCache::Data core
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QDeclarativeContextData * context
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
QDeclarativeValueTypeFactory valueTypes
QDeclarativePropertyPrivate * d
QDeclarativeGuard< QObject > object
const char * typeName() const
Returns the name of this property&#39;s type.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.
QDeclarativePropertyCache::ValueTypeData valueType

◆ read() [1/4]

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

922 {
923  if (!d)
924  return QVariant();
925  if (!d->object)
926  return QVariant();
927 
928  if (type() & SignalProperty) {
929 
930  return QVariant();
931 
932  } else if (type() & Property) {
933 
934  return d->readValueProperty();
935 
936  }
937  return QVariant();
938 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
Type type() const
Returns the type of the property.
QDeclarativePropertyPrivate * d
QDeclarativeGuard< QObject > object

◆ read() [2/4]

QVariant QDeclarativeProperty::read ( QObject object,
const QString name 
)
static

Return the name property value of object.

This method is equivalent to:

p.read();

Definition at line 947 of file qdeclarativeproperty.cpp.

948 {
949  QDeclarativeProperty p(object, name);
950  return p.read();
951 }
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...

◆ read() [3/4]

QVariant QDeclarativeProperty::read ( QObject object,
const QString name,
QDeclarativeContext ctxt 
)
static

Return the name property value of object using the context ctxt.

This method is equivalent to:

QDeclarativeProperty p(object, name, context);
p.read();

Definition at line 963 of file qdeclarativeproperty.cpp.

964 {
965  QDeclarativeProperty p(object, name, ctxt);
966  return p.read();
967 }
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...

◆ read() [4/4]

QVariant QDeclarativeProperty::read ( QObject object,
const QString name,
QDeclarativeEngine engine 
)
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:

QDeclarativeProperty p(object, name, engine);
p.read();

Definition at line 980 of file qdeclarativeproperty.cpp.

981 {
982  QDeclarativeProperty p(object, name, engine);
983  return p.read();
984 }
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...

◆ reset()

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.

1335 {
1336  if (isResettable()) {
1337  void *args[] = { 0 };
1339  return true;
1340  } else {
1341  return false;
1342  }
1343 }
bool isResettable() const
Returns true if the property is resettable, otherwise false.
static int metacall(QObject *, Call, int, void **)
QDeclarativePropertyCache::Data core
QDeclarativePropertyPrivate * d
QDeclarativeGuard< QObject > object

◆ type()

QDeclarativeProperty::Type QDeclarativeProperty::type ( ) const

◆ write() [1/4]

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

1273 {
1274  return QDeclarativePropertyPrivate::write(*this, value, 0);
1275 }
static bool write(QObject *, const QDeclarativePropertyCache::Data &, const QVariant &, QDeclarativeContextData *, WriteFlags flags=0)

◆ write() [2/4]

bool QDeclarativeProperty::write ( QObject object,
const QString name,
const QVariant value 
)
static

Writes value to the name property of object.

This method is equivalent to:

p.write(value);

Definition at line 1286 of file qdeclarativeproperty.cpp.

1287 {
1288  QDeclarativeProperty p(object, name);
1289  return p.write(value);
1290 }
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...

◆ write() [3/4]

bool QDeclarativeProperty::write ( QObject object,
const QString name,
const QVariant value,
QDeclarativeContext ctxt 
)
static

Writes value to the name property of object using the context ctxt.

This method is equivalent to:

QDeclarativeProperty p(object, name, ctxt);
p.write(value);

Definition at line 1302 of file qdeclarativeproperty.cpp.

1306 {
1307  QDeclarativeProperty p(object, name, ctxt);
1308  return p.write(value);
1309 }
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...

◆ write() [4/4]

bool QDeclarativeProperty::write ( QObject object,
const QString name,
const QVariant value,
QDeclarativeEngine engine 
)
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:

QDeclarativeProperty p(object, name, engine);
p.write(value);

Definition at line 1322 of file qdeclarativeproperty.cpp.

1324 {
1325  QDeclarativeProperty p(object, name, engine);
1326  return p.write(value);
1327 }
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...

Friends and Related Functions

◆ QDeclarativePropertyPrivate

Definition at line 129 of file qdeclarativeproperty.h.

Referenced by QDeclarativePropertyPrivate::restore().

Properties

◆ d

QDeclarativePropertyPrivate* QDeclarativeProperty::d
private

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