Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QDeclarativeProperty Class

TheQDeclarativeProperty class abstracts accessing properties on objects created from QML.More...

Header:#include <QDeclarativeProperty>
Since: Qt 4.7

Public Types

enumPropertyTypeCategory { InvalidCategory, List, Object, Normal }
enumType { Invalid, Property, SignalProperty }

Public Functions

QDeclarativeProperty()
QDeclarativeProperty(QObject * obj)
QDeclarativeProperty(QObject * obj, QDeclarativeContext * ctxt)
QDeclarativeProperty(QObject * obj, QDeclarativeEngine * engine)
QDeclarativeProperty(QObject * obj, const QString & name)
QDeclarativeProperty(QObject * obj, const QString & name, QDeclarativeContext * ctxt)
QDeclarativeProperty(QObject * obj, const QString & name, QDeclarativeEngine * engine)
QDeclarativeProperty(const QDeclarativeProperty & other)
boolconnectNotifySignal(QObject * dest, const char * slot) const
boolconnectNotifySignal(QObject * dest, int method) const
boolhasNotifySignal() const
intindex() const
boolisDesignable() const
boolisProperty() const
boolisResettable() const
boolisSignalProperty() const
boolisValid() const
boolisWritable() const
QMetaMethodmethod() const
QStringname() const
boolneedsNotifySignal() const
QObject *object() const
QMetaPropertyproperty() const
intpropertyType() const
PropertyTypeCategorypropertyTypeCategory() const
const char *propertyTypeName() const
QVariantread() const
boolreset() const
Typetype() const
boolwrite(const QVariant & value) const
QDeclarativeProperty &operator=(const QDeclarativeProperty & other)
booloperator==(const QDeclarativeProperty & other) const

Static Public Members

QVariantread(QObject * object, const QString & name)
QVariantread(QObject * object, const QString & name, QDeclarativeContext * ctxt)
QVariantread(QObject * object, const QString & name, QDeclarativeEngine * engine)
boolwrite(QObject * object, const QString & name, const QVariant & value)
boolwrite(QObject * object, const QString & name, const QVariant & value, QDeclarativeContext * ctxt)
boolwrite(QObject * object, const QString & name, const QVariant & value, QDeclarativeEngine * engine)

Detailed Description

TheQDeclarativeProperty class abstracts accessing properties on objects created from QML.

As QML uses Qt's meta-type system all of the existingQMetaObject 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 theQDeclarativeProperty class that simplifies some of their natural complexity.

UnlikeQMetaProperty 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 aQDeclarativeProperty instance and call theread() method. Likewise to write a property value thewrite() method is used.

For example, for the following QML code:

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

TheText object's properties could be accessed usingQDeclarativeProperty, like this:

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

Member Type Documentation

enum QDeclarativeProperty::PropertyTypeCategory

This enum specifies a category of QML property.

ConstantValueDescription
QDeclarativeProperty::InvalidCategory0The property is invalid, or is a signal property.
QDeclarativeProperty::List1The property is aQDeclarativeListProperty list property
QDeclarativeProperty::Object2The property is aQObject derived type pointer
QDeclarativeProperty::Normal3The property is a normal value property.

enum QDeclarativeProperty::Type

This enum specifies a type of QML property.

ConstantValueDescription
QDeclarativeProperty::Invalid0The property is invalid.
QDeclarativeProperty::Property1The property is a regular Qt property.
QDeclarativeProperty::SignalProperty2The property is a signal property.

Member Function Documentation

QDeclarativeProperty::QDeclarativeProperty()

Create an invalidQDeclarativeProperty.

QDeclarativeProperty::QDeclarativeProperty(QObject * obj)

Creates aQDeclarativeProperty for the default property ofobj. If there is no default property, an invalidQDeclarativeProperty will be created.

QDeclarativeProperty::QDeclarativeProperty(QObject * obj,QDeclarativeContext * ctxt)

Creates aQDeclarativeProperty for the default property ofobj using thecontextctxt. If there is no default property, an invalidQDeclarativeProperty will be created.

QDeclarativeProperty::QDeclarativeProperty(QObject * obj,QDeclarativeEngine * engine)

Creates aQDeclarativeProperty for the default property ofobj using the environment for instantiating QML components that is provided byengine. If there is no default property, an invalidQDeclarativeProperty will be created.

QDeclarativeProperty::QDeclarativeProperty(QObject * obj, constQString & name)

Creates aQDeclarativeProperty for the propertyname ofobj.

QDeclarativeProperty::QDeclarativeProperty(QObject * obj, constQString & name,QDeclarativeContext * ctxt)

Creates aQDeclarativeProperty for the propertyname ofobj using thecontextctxt.

Creating aQDeclarativeProperty without a context will render some properties - like attached properties - inaccessible.

QDeclarativeProperty::QDeclarativeProperty(QObject * obj, constQString & name,QDeclarativeEngine * engine)

Creates aQDeclarativeProperty for the propertyname ofobj using the environment for instantiating QML components that is provided byengine.

QDeclarativeProperty::QDeclarativeProperty(constQDeclarativeProperty & other)

Create a copy ofother.

bool QDeclarativeProperty::connectNotifySignal(QObject * dest, constchar * slot) const

Connects the property's change notifier signal to the specifiedslot of thedest 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 thedest object does not have the specifiedslot.

bool QDeclarativeProperty::connectNotifySignal(QObject * dest,int method) const

Connects the property's change notifier signal to the specifiedmethod of thedest 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 thedest object does not have the specifiedmethod.

bool QDeclarativeProperty::hasNotifySignal() const

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

int QDeclarativeProperty::index() const

Return the Qt metaobject index of the property.

bool QDeclarativeProperty::isDesignable() const

Returns true if the property is designable, otherwise false.

bool QDeclarativeProperty::isProperty() const

Returns true if thisQDeclarativeProperty represents a regular Qt property.

bool QDeclarativeProperty::isResettable() const

Returns true if the property is resettable, otherwise false.

bool QDeclarativeProperty::isSignalProperty() const

Returns true if thisQDeclarativeProperty represents a QML signal property.

bool QDeclarativeProperty::isValid() const

Returns true if theQDeclarativeProperty refers to a valid property, otherwise false.

bool QDeclarativeProperty::isWritable() const

Returns true if the property is writable, otherwise false.

QMetaMethod QDeclarativeProperty::method() const

Return theQMetaMethod for this property if it is aSignalProperty, otherwise returns an invalidQMetaMethod.

QString QDeclarativeProperty::name() const

Return the name of this QML property.

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.

QObject * QDeclarativeProperty::object() const

Returns theQDeclarativeProperty'sQObject.

QMetaProperty QDeclarativeProperty::property() const

Returns theQt property associated with this QML property.

int QDeclarativeProperty::propertyType() const

Returns theQVariant type of the property, orQVariant::Invalid if the property has noQVariant type.

PropertyTypeCategory QDeclarativeProperty::propertyTypeCategory() const

Returns the property category.

constchar * QDeclarativeProperty::propertyTypeName() const

Returns the type name of the property, or 0 if the property has no type name.

QVariant QDeclarativeProperty::read() const

Returns the property value.

[static]QVariant QDeclarativeProperty::read(QObject * object, constQString & name)

Return thename property value ofobject. This method is equivalent to:

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

[static]QVariant QDeclarativeProperty::read(QObject * object, constQString & name,QDeclarativeContext * ctxt)

Return thename property value ofobject using thecontextctxt. This method is equivalent to:

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

[static]QVariant QDeclarativeProperty::read(QObject * object, constQString & name,QDeclarativeEngine * engine)

Return thename property value ofobject using the environment for instantiating QML components that is provided byengine. . This method is equivalent to:

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

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.

Type QDeclarativeProperty::type() const

Returns the type of the property.

bool QDeclarativeProperty::write(constQVariant & value) const

Sets the property value tovalue and returns true. Returns false if the property can't be set because thevalue is the wrong type, for example.

[static]bool QDeclarativeProperty::write(QObject * object, constQString & name, constQVariant & value)

Writesvalue to thename property ofobject. This method is equivalent to:

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

[static]bool QDeclarativeProperty::write(QObject * object, constQString & name, constQVariant & value,QDeclarativeContext * ctxt)

Writesvalue to thename property ofobject using thecontextctxt. This method is equivalent to:

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

[static]bool QDeclarativeProperty::write(QObject * object, constQString & name, constQVariant & value,QDeclarativeEngine * engine)

Writesvalue to thename property ofobject using the environment for instantiating QML components that is provided byengine. This method is equivalent to:

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

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

Assignother to thisQDeclarativeProperty.

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

Returns true ifother and thisQDeclarativeProperty represent the same property.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp