Struct QQmlListReference

Source
#[repr(C)]
pub struct QQmlListReference { /* private fields */ }
Expand description

QQmlListReference allows C++ programs to read from, and assign values to a QML list property in a simple and type-safe way. A QQmlListReference can be created by passing an object and property name or through a QQmlProperty instance. These two are equivalent:

C++ class: QQmlListReference.

C++ documentation:

QQmlListReference allows C++ programs to read from, and assign values to a QML list property in a simple and type-safe way. A QQmlListReference can be created by passing an object and property name or through a QQmlProperty instance. These two are equivalent:


  QQmlListReference ref1(object, "children");

  QQmlProperty ref2(object, "children");
  QQmlListReference ref2 = qvariant_cast<QQmlListReference>(ref2.read());

Not all QML list properties support all operations. A set of methods, canAppend(), canAt(), canClear() and canCount() allow programs to query whether an operation is supported on a given property.

QML list properties are type-safe. Only QObject's that derive from the correct base class can be assigned to the list. The listElementType() method can be used to query the QMetaObject of the QObject type supported. Attempting to add objects of the incorrect type to a list property will fail.

Like with normal lists, when accessing a list element by index, it is the callers responsibility to ensure that it does not request an out of range element using the count() method before calling at().

Implementations§

Source§

impl QQmlListReference

Source

pub unsafe fn append(&self, arg1: impl CastInto<Ptr<QObject>>) -> bool

Appends object to the list. Returns true if the operation succeeded, otherwise false.

Calls C++ function: bool QQmlListReference::append(QObject* arg1) const.

C++ documentation:

Appends object to the list. Returns true if the operation succeeded, otherwise false.

See also canAppend().

Source

pub unsafe fn at(&self, arg1: c_int) -> QPtr<QObject>

Returns the list element at index, or 0 if the operation failed.

Calls C++ function: QObject* QQmlListReference::at(int arg1) const.

C++ documentation:

Returns the list element at index, or 0 if the operation failed.

See also canAt().

Source

pub unsafe fn can_append(&self) -> bool

Returns true if the list property can be appended to, otherwise false. Returns false if the reference is invalid.

Calls C++ function: bool QQmlListReference::canAppend() const.

C++ documentation:

Returns true if the list property can be appended to, otherwise false. Returns false if the reference is invalid.

See also append().

Source

pub unsafe fn can_at(&self) -> bool

Returns true if the list property can queried by index, otherwise false. Returns false if the reference is invalid.

Calls C++ function: bool QQmlListReference::canAt() const.

C++ documentation:

Returns true if the list property can queried by index, otherwise false. Returns false if the reference is invalid.

See also at().

Source

pub unsafe fn can_clear(&self) -> bool

Returns true if the list property can be cleared, otherwise false. Returns false if the reference is invalid.

Calls C++ function: bool QQmlListReference::canClear() const.

C++ documentation:

Returns true if the list property can be cleared, otherwise false. Returns false if the reference is invalid.

See also clear().

Source

pub unsafe fn can_count(&self) -> bool

Returns true if the list property can be queried for its element count, otherwise false. Returns false if the reference is invalid.

Calls C++ function: bool QQmlListReference::canCount() const.

C++ documentation:

Returns true if the list property can be queried for its element count, otherwise false. Returns false if the reference is invalid.

See also count().

Source

pub unsafe fn clear(&self) -> bool

Clears the list. Returns true if the operation succeeded, otherwise false.

Calls C++ function: bool QQmlListReference::clear() const.

C++ documentation:

Clears the list. Returns true if the operation succeeded, otherwise false.

See also canClear().

Source

pub unsafe fn copy_from( &self, arg1: impl CastInto<Ref<QQmlListReference>>, ) -> Ref<QQmlListReference>

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

Source

pub unsafe fn count(&self) -> c_int

Returns the number of objects in the list, or 0 if the operation failed.

Calls C++ function: int QQmlListReference::count() const.

C++ documentation:

Returns the number of objects in the list, or 0 if the operation failed.

Source

pub unsafe fn is_manipulable(&self) -> bool

Return true if at(), count(), append() and clear() are implemented, so you can manipulate the list.

Calls C++ function: bool QQmlListReference::isManipulable() const.

C++ documentation:

Return true if at(), count(), append() and clear() are implemented, so you can manipulate the list.

See also isReadable(), at(), count(), append(), and clear().

Source

pub unsafe fn is_readable(&self) -> bool

Return true if at() and count() are implemented, so you can access the elements.

Calls C++ function: bool QQmlListReference::isReadable() const.

C++ documentation:

Return true if at() and count() are implemented, so you can access the elements.

See also isManipulable(), at(), and count().

Source

pub unsafe fn is_valid(&self) -> bool

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

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

C++ documentation:

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

Source

pub unsafe fn list_element_type(&self) -> Ptr<QMetaObject>

Returns the QMetaObject for the elements stored in the list property, or nullptr if the reference is invalid.

Calls C++ function: const QMetaObject* QQmlListReference::listElementType() const.

C++ documentation:

Returns the QMetaObject for the elements stored in the list property, or nullptr if the reference is invalid.

The QMetaObject can be used ahead of time to determine whether a given instance can be added to a list.

Source

pub unsafe fn new_0a() -> CppBox<QQmlListReference>

Constructs an invalid instance.

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

C++ documentation:

Constructs an invalid instance.

Source

pub unsafe fn new_3a( arg1: impl CastInto<Ptr<QObject>>, property: *const c_char, arg3: impl CastInto<Ptr<QQmlEngine>>, ) -> CppBox<QQmlListReference>

Constructs a QQmlListReference for object's property. If property is not a list property, an invalid QQmlListReference is created. If object is destroyed after the reference is constructed, it will automatically become invalid. That is, it is safe to hold QQmlListReference instances even after object is deleted.

Calls C++ function: [constructor] void QQmlListReference::QQmlListReference(QObject* arg1, const char* property, QQmlEngine* arg3 = …).

C++ documentation:

Constructs a QQmlListReference for object’s property. If property is not a list property, an invalid QQmlListReference is created. If object is destroyed after the reference is constructed, it will automatically become invalid. That is, it is safe to hold QQmlListReference instances even after object is deleted.

Passing engine is required to access some QML created list properties. If in doubt, and an engine is available, pass it.

Source

pub unsafe fn new_2a( arg1: impl CastInto<Ptr<QObject>>, property: *const c_char, ) -> CppBox<QQmlListReference>

Constructs a QQmlListReference for object's property. If property is not a list property, an invalid QQmlListReference is created. If object is destroyed after the reference is constructed, it will automatically become invalid. That is, it is safe to hold QQmlListReference instances even after object is deleted.

Calls C++ function: [constructor] void QQmlListReference::QQmlListReference(QObject* arg1, const char* property).

C++ documentation:

Constructs a QQmlListReference for object’s property. If property is not a list property, an invalid QQmlListReference is created. If object is destroyed after the reference is constructed, it will automatically become invalid. That is, it is safe to hold QQmlListReference instances even after object is deleted.

Passing engine is required to access some QML created list properties. If in doubt, and an engine is available, pass it.

Source

pub unsafe fn new_copy( arg1: impl CastInto<Ref<QQmlListReference>>, ) -> CppBox<QQmlListReference>

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

Source

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

Returns the list property's object. Returns nullptr if the reference is invalid.

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

C++ documentation:

Returns the list property’s object. Returns nullptr if the reference is invalid.

Trait Implementations§

Source§

impl CppDeletable for QQmlListReference

Source§

unsafe fn delete(&self)

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

Source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> StaticUpcast<T> for T

Source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.