[][src]Struct qt_qml::QQmlProperty

#[repr(C)]pub struct QQmlProperty { /* fields omitted */ }

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.

C++ class: QQmlProperty.

C++ documentation:

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:

// MyItem.qml import QtQuick 2.0

Text { text: "A bit of text" }

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

#include <QQmlProperty> #include <QGraphicsObject>

...

QQuickView view(QUrl::fromLocalFile("MyItem.qml")); QQmlProperty 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();

Methods

impl QQmlProperty[src]

pub unsafe fn connect_notify_signal_q_object_char(
    &self,
    dest: impl CastInto<Ptr<QObject>>,
    slot: *const c_char
) -> bool
[src]

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.

Calls C++ function: bool QQmlProperty::connectNotifySignal(QObject* dest, const char* slot) const.

C++ documentation:

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.

Note: slot should be passed using the SLOT() macro so it is correctly identified.

pub unsafe fn connect_notify_signal_q_object_int(
    &self,
    dest: impl CastInto<Ptr<QObject>>,
    method: c_int
) -> bool
[src]

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.

Calls C++ function: bool QQmlProperty::connectNotifySignal(QObject* dest, int method) const.

C++ documentation:

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.

pub unsafe fn copy_from(
    &self,
    arg1: impl CastInto<Ref<QQmlProperty>>
) -> Ref<QQmlProperty>
[src]

Assign other to this QQmlProperty.

Calls C++ function: QQmlProperty& QQmlProperty::operator=(const QQmlProperty& arg1).

C++ documentation:

Assign other to this QQmlProperty.

pub unsafe fn has_notify_signal(&self) -> bool[src]

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

Calls C++ function: bool QQmlProperty::hasNotifySignal() const.

C++ documentation:

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

pub unsafe fn index(&self) -> c_int[src]

Return the Qt metaobject index of the property.

Calls C++ function: int QQmlProperty::index() const.

C++ documentation:

Return the Qt metaobject index of the property.

pub unsafe fn is_designable(&self) -> bool[src]

Returns true if the property is designable, otherwise false.

Calls C++ function: bool QQmlProperty::isDesignable() const.

C++ documentation:

Returns true if the property is designable, otherwise false.

pub unsafe fn is_property(&self) -> bool[src]

Returns true if this QQmlProperty represents a regular Qt property.

Calls C++ function: bool QQmlProperty::isProperty() const.

C++ documentation:

Returns true if this QQmlProperty represents a regular Qt property.

pub unsafe fn is_resettable(&self) -> bool[src]

Returns true if the property is resettable, otherwise false.

Calls C++ function: bool QQmlProperty::isResettable() const.

C++ documentation:

Returns true if the property is resettable, otherwise false.

pub unsafe fn is_signal_property(&self) -> bool[src]

Returns true if this QQmlProperty represents a QML signal property.

Calls C++ function: bool QQmlProperty::isSignalProperty() const.

C++ documentation:

Returns true if this QQmlProperty represents a QML signal property.

pub unsafe fn is_valid(&self) -> bool[src]

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

Calls C++ function: bool QQmlProperty::isValid() const.

C++ documentation:

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

pub unsafe fn is_writable(&self) -> bool[src]

Returns true if the property is writable, otherwise false.

Calls C++ function: bool QQmlProperty::isWritable() const.

C++ documentation:

Returns true if the property is writable, otherwise false.

pub unsafe fn method(&self) -> CppBox<QMetaMethod>[src]

Return the QMetaMethod for this property if it is a SignalProperty, otherwise returns an invalid QMetaMethod.

Calls C++ function: QMetaMethod QQmlProperty::method() const.

C++ documentation:

Return the QMetaMethod for this property if it is a SignalProperty, otherwise returns an invalid QMetaMethod.

pub unsafe fn name(&self) -> CppBox<QString>[src]

Return the name of this QML property.

Calls C++ function: QString QQmlProperty::name() const.

C++ documentation:

Return the name of this QML property.

pub unsafe fn needs_notify_signal(&self) -> bool[src]

Returns true if the property needs a change notifier signal for bindings to remain upto date, false otherwise.

Calls C++ function: bool QQmlProperty::needsNotifySignal() const.

C++ documentation:

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.

pub unsafe fn new() -> CppBox<QQmlProperty>[src]

Create an invalid QQmlProperty.

Calls C++ function: [constructor] void QQmlProperty::QQmlProperty().

C++ documentation:

Create an invalid QQmlProperty.

pub unsafe fn from_q_object(
    arg1: impl CastInto<Ptr<QObject>>
) -> CppBox<QQmlProperty>
[src]

Creates a QQmlProperty for the default property of obj. If there is no default property, an invalid QQmlProperty will be created.

Calls C++ function: [constructor] void QQmlProperty::QQmlProperty(QObject* arg1).

C++ documentation:

Creates a QQmlProperty for the default property of obj. If there is no default property, an invalid QQmlProperty will be created.

pub unsafe fn from_q_object_q_qml_context(
    arg1: impl CastInto<Ptr<QObject>>,
    arg2: impl CastInto<Ptr<QQmlContext>>
) -> CppBox<QQmlProperty>
[src]

Creates a QQmlProperty for the default property of obj using the context ctxt. If there is no default property, an invalid QQmlProperty will be created.

Calls C++ function: [constructor] void QQmlProperty::QQmlProperty(QObject* arg1, QQmlContext* arg2).

C++ documentation:

Creates a QQmlProperty for the default property of obj using the context ctxt. If there is no default property, an invalid QQmlProperty will be created.

pub unsafe fn from_q_object_q_qml_engine(
    arg1: impl CastInto<Ptr<QObject>>,
    arg2: impl CastInto<Ptr<QQmlEngine>>
) -> CppBox<QQmlProperty>
[src]

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.

Calls C++ function: [constructor] void QQmlProperty::QQmlProperty(QObject* arg1, QQmlEngine* arg2).

C++ documentation:

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.

pub unsafe fn from_q_object_q_string(
    arg1: impl CastInto<Ptr<QObject>>,
    arg2: impl CastInto<Ref<QString>>
) -> CppBox<QQmlProperty>
[src]

Creates a QQmlProperty for the property name of obj.

Calls C++ function: [constructor] void QQmlProperty::QQmlProperty(QObject* arg1, const QString& arg2).

C++ documentation:

Creates a QQmlProperty for the property name of obj.

pub unsafe fn from_q_object_q_string_q_qml_context(
    arg1: impl CastInto<Ptr<QObject>>,
    arg2: impl CastInto<Ref<QString>>,
    arg3: impl CastInto<Ptr<QQmlContext>>
) -> CppBox<QQmlProperty>
[src]

Creates a QQmlProperty for the property name of obj using the context ctxt.

Calls C++ function: [constructor] void QQmlProperty::QQmlProperty(QObject* arg1, const QString& arg2, QQmlContext* arg3).

C++ documentation:

Creates a QQmlProperty for the property name of obj using the context ctxt.

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

pub unsafe fn from_q_object_q_string_q_qml_engine(
    arg1: impl CastInto<Ptr<QObject>>,
    arg2: impl CastInto<Ref<QString>>,
    arg3: impl CastInto<Ptr<QQmlEngine>>
) -> CppBox<QQmlProperty>
[src]

Creates a QQmlProperty for the property name of obj using the environment for instantiating QML components that is provided by engine.

Calls C++ function: [constructor] void QQmlProperty::QQmlProperty(QObject* arg1, const QString& arg2, QQmlEngine* arg3).

C++ documentation:

Creates a QQmlProperty for the property name of obj using the environment for instantiating QML components that is provided by engine.

pub unsafe fn new_copy(
    arg1: impl CastInto<Ref<QQmlProperty>>
) -> CppBox<QQmlProperty>
[src]

Create a copy of other.

Calls C++ function: [constructor] void QQmlProperty::QQmlProperty(const QQmlProperty& arg1).

C++ documentation:

Create a copy of other.

pub unsafe fn object(&self) -> QPtr<QObject>[src]

Returns the QQmlProperty's QObject.

Calls C++ function: QObject* QQmlProperty::object() const.

C++ documentation:

Returns the QQmlProperty's QObject.

pub unsafe fn property(&self) -> CppBox<QMetaProperty>[src]

Returns the Qt property associated with this QML property.

Calls C++ function: QMetaProperty QQmlProperty::property() const.

C++ documentation:

Returns the Qt property associated with this QML property.

pub unsafe fn property_type(&self) -> c_int[src]

Returns the QVariant type of the property, or QVariant::Invalid if the property has no QVariant type.

Calls C++ function: int QQmlProperty::propertyType() const.

C++ documentation:

Returns the QVariant type of the property, or QVariant::Invalid if the property has no QVariant type.

pub unsafe fn property_type_category(&self) -> PropertyTypeCategory[src]

Returns the property category.

Calls C++ function: QQmlProperty::PropertyTypeCategory QQmlProperty::propertyTypeCategory() const.

C++ documentation:

Returns the property category.

pub unsafe fn property_type_name(&self) -> *const c_char[src]

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

Calls C++ function: const char* QQmlProperty::propertyTypeName() const.

C++ documentation:

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

pub unsafe fn read(&self) -> CppBox<QVariant>[src]

Returns the property value.

Calls C++ function: QVariant QQmlProperty::read() const.

C++ documentation:

Returns the property value.

pub unsafe fn read_q_object_q_string(
    arg1: impl CastInto<Ptr<QObject>>,
    arg2: impl CastInto<Ref<QString>>
) -> CppBox<QVariant>
[src]

Return the name property value of object. This method is equivalent to:

Calls C++ function: static QVariant QQmlProperty::read(const QObject* arg1, const QString& arg2).

C++ documentation:

Return the name property value of object. This method is equivalent to:


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

pub unsafe fn read_q_object_q_string_q_qml_context(
    arg1: impl CastInto<Ptr<QObject>>,
    arg2: impl CastInto<Ref<QString>>,
    arg3: impl CastInto<Ptr<QQmlContext>>
) -> CppBox<QVariant>
[src]

Return the name property value of object using the context ctxt. This method is equivalent to:

Calls C++ function: static QVariant QQmlProperty::read(const QObject* arg1, const QString& arg2, QQmlContext* arg3).

C++ documentation:

Return the name property value of object using the context ctxt. This method is equivalent to:


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

pub unsafe fn read_q_object_q_string_q_qml_engine(
    arg1: impl CastInto<Ptr<QObject>>,
    arg2: impl CastInto<Ref<QString>>,
    arg3: impl CastInto<Ptr<QQmlEngine>>
) -> CppBox<QVariant>
[src]

Return the name property value of object using the environment for instantiating QML components that is provided by engine. . This method is equivalent to:

Calls C++ function: static QVariant QQmlProperty::read(const QObject* arg1, const QString& arg2, QQmlEngine* arg3).

C++ documentation:

Return the name property value of object using the environment for instantiating QML components that is provided by engine. . This method is equivalent to:


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

pub unsafe fn reset(&self) -> bool[src]

Resets the property and returns true if the property is resettable. If the property is not resettable, nothing happens and false is returned.

Calls C++ function: bool QQmlProperty::reset() const.

C++ documentation:

Resets the property and returns true if the property is resettable. If the property is not resettable, nothing happens and false is returned.

pub unsafe fn type_(&self) -> Type[src]

Returns the type of the property.

Calls C++ function: QQmlProperty::Type QQmlProperty::type() const.

C++ documentation:

Returns the type of the property.

pub unsafe fn write_q_variant(&self, arg1: impl CastInto<Ref<QVariant>>) -> bool[src]

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.

Calls C++ function: bool QQmlProperty::write(const QVariant& arg1) const.

C++ documentation:

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.

pub unsafe fn write_q_object_q_string_q_variant(
    arg1: impl CastInto<Ptr<QObject>>,
    arg2: impl CastInto<Ref<QString>>,
    arg3: impl CastInto<Ref<QVariant>>
) -> bool
[src]

Writes value to the name property of object. This method is equivalent to:

Calls C++ function: static bool QQmlProperty::write(QObject* arg1, const QString& arg2, const QVariant& arg3).

C++ documentation:

Writes value to the name property of object. This method is equivalent to:


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

Returns true on success, false otherwise.

pub unsafe fn write_q_object_q_string_q_variant_q_qml_context(
    arg1: impl CastInto<Ptr<QObject>>,
    arg2: impl CastInto<Ref<QString>>,
    arg3: impl CastInto<Ref<QVariant>>,
    arg4: impl CastInto<Ptr<QQmlContext>>
) -> bool
[src]

Writes value to the name property of object using the context ctxt. This method is equivalent to:

Calls C++ function: static bool QQmlProperty::write(QObject* arg1, const QString& arg2, const QVariant& arg3, QQmlContext* arg4).

C++ documentation:

Writes value to the name property of object using the context ctxt. This method is equivalent to:


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

Returns true on success, false otherwise.

pub unsafe fn write_q_object_q_string_q_variant_q_qml_engine(
    arg1: impl CastInto<Ptr<QObject>>,
    arg2: impl CastInto<Ref<QString>>,
    arg3: impl CastInto<Ref<QVariant>>,
    arg4: impl CastInto<Ptr<QQmlEngine>>
) -> bool
[src]

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:

Calls C++ function: static bool QQmlProperty::write(QObject* arg1, const QString& arg2, const QVariant& arg3, QQmlEngine* arg4).

C++ documentation:

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:


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

Returns true on success, false otherwise.

Trait Implementations

impl CppDeletable for QQmlProperty[src]

unsafe fn delete(&self)[src]

Calls C++ function: [destructor] void QQmlProperty::~QQmlProperty().

impl PartialEq<Ref<QQmlProperty>> for QQmlProperty[src]

fn eq(&self, arg1: &Ref<QQmlProperty>) -> bool[src]

Returns true if other and this QQmlProperty represent the same property.

Calls C++ function: bool QQmlProperty::operator==(const QQmlProperty& arg1) const.

C++ documentation:

Returns true if other and this QQmlProperty represent the same property.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.