![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
The QQmlProperty class abstracts accessing properties on objects created from QML. More...
#include <qqmlproperty.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 Member Functions | |
| QQmlProperty () | |
| Create an invalid QQmlProperty. | |
| ~QQmlProperty () | |
| QQmlProperty (QObject *) | |
| Creates a QQmlProperty for the default property of obj. | |
| QQmlProperty (QObject *, QQmlContext *) | |
| Creates a QQmlProperty for the default property of obj using the \l{QQmlContext} {context} ctxt. | |
| QQmlProperty (QObject *, QQmlEngine *) | |
| Creates a QQmlProperty for the default property of obj using the environment for instantiating QML components that is provided by engine. | |
| QQmlProperty (QObject *, const QString &) | |
| Creates a QQmlProperty for the property name of obj. | |
| QQmlProperty (QObject *, const QString &, QQmlContext *) | |
| Creates a QQmlProperty for the property name of obj using the \l{QQmlContext} {context} ctxt. | |
| QQmlProperty (QObject *, const QString &, QQmlEngine *) | |
| Creates a QQmlProperty for the property name of obj using the environment for instantiating QML components that is provided by engine. | |
| QQmlProperty (const QQmlProperty &) | |
| Create a copy of other. | |
| QQmlProperty & | operator= (const QQmlProperty &) |
| Assign other to this QQmlProperty. | |
| QQmlProperty (QQmlProperty &&other) noexcept | |
| void | swap (QQmlProperty &other) noexcept |
| bool | operator== (const QQmlProperty &) const |
| Returns true if other and this QQmlProperty represent the same property. | |
| Type | type () const |
| Returns the type of the property. | |
| bool | isValid () const |
| Returns true if the QQmlProperty refers to a valid property, otherwise false. | |
| bool | isProperty () const |
| Returns true if this QQmlProperty represents a regular Qt property. | |
| bool | isSignalProperty () const |
| Returns true if this QQmlProperty represents a QML signal property. | |
| int | propertyType () const |
| Returns the metatype id of the property, or QMetaType::UnknownType if the property has no metatype. | |
| QMetaType | propertyMetaType () const |
| Returns the metatype of the property. | |
| PropertyTypeCategory | propertyTypeCategory () const |
| Returns the property category. | |
| const char * | propertyTypeName () const |
| Returns the type name of the property, or 0 if the property has no type name. | |
| QString | name () const |
| Return the name of this QML property. | |
| QVariant | read () const |
| Returns the property value. | |
| bool | write (const QVariant &) const |
| Sets the property value to value. | |
| bool | reset () const |
| Resets the property and returns true if the property is resettable. | |
| bool | hasNotifySignal () const |
| Returns true if the property has a change notifier signal, otherwise false. | |
| bool | needsNotifySignal () const |
| Returns true if the property needs a change notifier signal for bindings to remain upto date, false otherwise. | |
| 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. | |
| 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. | |
| bool | isWritable () const |
| Returns true if the property is writable, otherwise false. | |
| bool | isBindable () const |
| bool | isDesignable () const |
| Returns true if the property is designable, otherwise false. | |
| bool | isResettable () const |
| Returns true if the property is resettable, otherwise false. | |
| QObject * | object () const |
| Returns the QQmlProperty's QObject. | |
| int | index () const |
| Return the Qt metaobject index of the property. | |
| QMetaProperty | property () const |
| Returns the \l{QMetaProperty} {Qt property} associated with this QML property. | |
| QMetaMethod | method () const |
| Return the QMetaMethod for this property if it is a SignalProperty, otherwise returns an invalid QMetaMethod. | |
Static Public Member Functions | |
| static QVariant | read (const QObject *, const QString &) |
| Return the name property value of object. | |
| static QVariant | read (const QObject *, const QString &, QQmlContext *) |
| Return the name property value of object using the \l{QQmlContext} {context} ctxt. | |
| static QVariant | read (const QObject *, const QString &, QQmlEngine *) |
| Return the name property value of object using the environment for instantiating QML components that is provided by engine. | |
| static bool | write (QObject *, const QString &, const QVariant &) |
| Writes value to the name property of object. | |
| static bool | write (QObject *, const QString &, const QVariant &, QQmlContext *) |
| Writes value to the name property of object using the \l{QQmlContext} {context} ctxt. | |
| static bool | write (QObject *, const QString &, const QVariant &, QQmlEngine *) |
| Writes value to the name property of object using the environment for instantiating QML components that is provided by engine. | |
Properties | |
| QML_ANONYMOUSQObject * | object |
| the QObject represented by the QML property. | |
| QString | name |
| the name of the QML property. | |
Friends | |
| class | QQmlPropertyPrivate |
The QQmlProperty 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 QQmlProperty class that simplifies some of their natural complexity.
Unlike QMetaProperty which represents a property on a class type, QQmlProperty encapsulates a property on a specific object instance. To read a property's value, programmers create a QQmlProperty instance and call the read() method. Likewise to write a property value the write() method is used.
For example, for the following QML code:
\qml MyItem.qml import QtQuick 2.0
Text { text: "A bit of text" } \endqml
The \l Text object's properties could be accessed using QQmlProperty, like this:
Definition at line 22 of file qqmlproperty.h.
This enum specifies a category of QML property.
\value InvalidCategory The property is invalid, or is a signal property. \value List The property is a QQmlListProperty list property \value Object The property is a QObject derived type pointer \value Normal The property is a normal value property.
| Enumerator | |
|---|---|
| InvalidCategory | |
| List | |
| Object | |
| Normal | |
Definition at line 30 of file qqmlproperty.h.
| enum QQmlProperty::Type |
This enum specifies a type of QML property.
\value Invalid The property is invalid. \value Property The property is a regular Qt property. \value SignalProperty The property is a signal property.
| Enumerator | |
|---|---|
| Invalid | |
| Property | |
| SignalProperty | |
Definition at line 37 of file qqmlproperty.h.
|
default |
Create an invalid QQmlProperty.
| QQmlProperty::~QQmlProperty | ( | ) |
Definition at line 94 of file qqmlproperty.cpp.
| QQmlProperty::QQmlProperty | ( | QObject * | obj | ) |
Creates a QQmlProperty for the default property of obj.
If there is no default property, an invalid QQmlProperty will be created.
Definition at line 105 of file qqmlproperty.cpp.
| QQmlProperty::QQmlProperty | ( | QObject * | obj, |
| QQmlContext * | ctxt ) |
Creates a QQmlProperty for the default property of obj using the \l{QQmlContext} {context} ctxt.
If there is no default property, an invalid QQmlProperty will be created.
Definition at line 117 of file qqmlproperty.cpp.
| QQmlProperty::QQmlProperty | ( | QObject * | obj, |
| QQmlEngine * | engine ) |
Creates a QQmlProperty 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 QQmlProperty will be created.
Definition at line 133 of file qqmlproperty.cpp.
Creates a QQmlProperty for the property name of obj.
Definition at line 157 of file qqmlproperty.cpp.
| QQmlProperty::QQmlProperty | ( | QObject * | obj, |
| const QString & | name, | ||
| QQmlContext * | ctxt ) |
Creates a QQmlProperty for the property name of obj using the \l{QQmlContext} {context} ctxt.
Creating a QQmlProperty without a context will render some properties - like attached properties - inaccessible.
Definition at line 171 of file qqmlproperty.cpp.
| QQmlProperty::QQmlProperty | ( | QObject * | obj, |
| const QString & | name, | ||
| QQmlEngine * | engine ) |
Creates a QQmlProperty for the property name of obj using the environment for instantiating QML components that is provided by engine.
Definition at line 192 of file qqmlproperty.cpp.
| QQmlProperty::QQmlProperty | ( | const QQmlProperty & | other | ) |
Create a copy of other.
Definition at line 490 of file qqmlproperty.cpp.
|
inlinenoexcept |
Definition at line 57 of file qqmlproperty.h.
| bool QQmlProperty::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 2188 of file qqmlproperty.cpp.
| bool QQmlProperty::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 2164 of file qqmlproperty.cpp.
| bool QQmlProperty::hasNotifySignal | ( | ) | const |
Returns true if the property has a change notifier signal, otherwise false.
Definition at line 2136 of file qqmlproperty.cpp.
| int QQmlProperty::index | ( | ) | const |
Return the Qt metaobject index of the property.
Definition at line 2205 of file qqmlproperty.cpp.
| bool QQmlProperty::isBindable | ( | ) | const |
Returns true if the property is bindable, otherwise false.
Definition at line 703 of file qqmlproperty.cpp.
| bool QQmlProperty::isDesignable | ( | ) | const |
Returns true if the property is designable, otherwise false.
Definition at line 717 of file qqmlproperty.cpp.
| bool QQmlProperty::isProperty | ( | ) | const |
Returns true if this QQmlProperty represents a regular Qt property.
Definition at line 643 of file qqmlproperty.cpp.
| bool QQmlProperty::isResettable | ( | ) | const |
Returns true if the property is resettable, otherwise false.
Definition at line 730 of file qqmlproperty.cpp.
| bool QQmlProperty::isSignalProperty | ( | ) | const |
Returns true if this QQmlProperty represents a QML signal property.
Definition at line 651 of file qqmlproperty.cpp.
| bool QQmlProperty::isValid | ( | ) | const |
Returns true if the QQmlProperty refers to a valid property, otherwise false.
Definition at line 744 of file qqmlproperty.cpp.
| bool QQmlProperty::isWritable | ( | ) | const |
Returns true if the property is writable, otherwise false.
Definition at line 683 of file qqmlproperty.cpp.
| QMetaMethod QQmlProperty::method | ( | ) | const |
Return the QMetaMethod for this property if it is a SignalProperty, otherwise returns an invalid QMetaMethod.
Definition at line 801 of file qqmlproperty.cpp.
| QString QQmlProperty::name | ( | ) | const |
Return the name of this QML property.
Definition at line 760 of file qqmlproperty.cpp.
| bool QQmlProperty::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 2151 of file qqmlproperty.cpp.
| QObject * QQmlProperty::object | ( | ) | const |
Returns the QQmlProperty's QObject.
Definition at line 665 of file qqmlproperty.cpp.
| QQmlProperty & QQmlProperty::operator= | ( | const QQmlProperty & | other | ) |
Assign other to this QQmlProperty.
Definition at line 673 of file qqmlproperty.cpp.
| bool QQmlProperty::operator== | ( | const QQmlProperty & | other | ) | const |
Returns true if other and this QQmlProperty represent the same property.
Definition at line 573 of file qqmlproperty.cpp.
| QMetaProperty QQmlProperty::property | ( | ) | const |
Returns the \l{QMetaProperty} {Qt property} associated with this QML property.
Definition at line 787 of file qqmlproperty.cpp.
| QMetaType QQmlProperty::propertyMetaType | ( | ) | const |
Returns the metatype of the property.
Definition at line 600 of file qqmlproperty.cpp.
| int QQmlProperty::propertyType | ( | ) | const |
Returns the metatype id of the property, or QMetaType::UnknownType if the property has no metatype.
Definition at line 590 of file qqmlproperty.cpp.
| QQmlProperty::PropertyTypeCategory QQmlProperty::propertyTypeCategory | ( | ) | const |
Returns the property category.
Definition at line 521 of file qqmlproperty.cpp.
| const char * QQmlProperty::propertyTypeName | ( | ) | const |
Returns the type name of the property, or 0 if the property has no type name.
Definition at line 554 of file qqmlproperty.cpp.
| QVariant QQmlProperty::read | ( | ) | const |
Returns the property value.
Definition at line 1093 of file qqmlproperty.cpp.
Return the name property value of object.
This method is equivalent to:
Definition at line 1119 of file qqmlproperty.cpp.
|
static |
Return the name property value of object using the \l{QQmlContext} {context} ctxt.
This method is equivalent to:
Definition at line 1135 of file qqmlproperty.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 1152 of file qqmlproperty.cpp.
| bool QQmlProperty::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 2110 of file qqmlproperty.cpp.
|
inlinenoexcept |
Definition at line 60 of file qqmlproperty.h.
| QQmlProperty::Type QQmlProperty::type | ( | ) | const |
Returns the type of the property.
Definition at line 635 of file qqmlproperty.cpp.
| bool QQmlProperty::write | ( | const QVariant & | value | ) | const |
Sets the property value to value.
Returns true on success, or false if the property can't be set because the value is the wrong type, for example.
Definition at line 2042 of file qqmlproperty.cpp.
Writes value to the name property of object.
This method is equivalent to:
Returns true on success, false otherwise.
Definition at line 2058 of file qqmlproperty.cpp.
|
static |
Writes value to the name property of object using the \l{QQmlContext} {context} ctxt.
This method is equivalent to:
Returns true on success, false otherwise.
Definition at line 2076 of file qqmlproperty.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:
Returns true on success, false otherwise.
Definition at line 2098 of file qqmlproperty.cpp.
|
friend |
Definition at line 103 of file qqmlproperty.h.
|
read |
the name of the QML property.
Definition at line 28 of file qqmlproperty.h.
Referenced by testing.tools.encode_pdf_filter._PdfStream::RegisterByName().
|
read |
the QObject represented by the QML property.
Definition at line 27 of file qqmlproperty.h.