[][src]Struct qt_qml::QJSValueIterator

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

The QJSValueIterator constructor takes a QJSValue as argument. After construction, the iterator is located at the very beginning of the sequence of properties. Here's how to iterate over all the properties of a QJSValue:

C++ class: QJSValueIterator.

C++ documentation:

The QJSValueIterator constructor takes a QJSValue as argument. After construction, the iterator is located at the very beginning of the sequence of properties. Here's how to iterate over all the properties of a QJSValue:


  QJSValue object;
  ...
  QJSValueIterator it(object);
  while (it.hasNext()) {
      it.next();
      qDebug() << it.name() << ": " << it.value().toString();
  }

The next() advances the iterator. The name() and value() functions return the name and value of the last item that was jumped over.

Note that QJSValueIterator only iterates over the QJSValue's own properties; i.e. it does not follow the prototype chain. You can use a loop like this to follow the prototype chain:

QJSValue obj = ...; // the object to iterate over while (obj.isObject()) { QJSValueIterator it(obj); while (it.hasNext()) { it.next(); qDebug() << it.name(); } obj = obj.prototype(); }

Methods

impl QJSValueIterator[src]

pub unsafe fn copy_from(
    &self,
    value: impl CastInto<Ref<QJSValue>>
) -> Ref<QJSValueIterator>
[src]

Makes the iterator operate on object. The iterator is set to be at the front of the sequence of properties (before the first property).

Calls C++ function: QJSValueIterator& QJSValueIterator::operator=(QJSValue& value).

C++ documentation:

Makes the iterator operate on object. The iterator is set to be at the front of the sequence of properties (before the first property).

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

Returns true if there is at least one item ahead of the iterator (i.e. the iterator is not at the back of the property sequence); otherwise returns false.

Calls C++ function: bool QJSValueIterator::hasNext() const.

C++ documentation:

Returns true if there is at least one item ahead of the iterator (i.e. the iterator is not at the back of the property sequence); otherwise returns false.

See also next().

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

Returns the name of the last property that was jumped over using next().

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

C++ documentation:

Returns the name of the last property that was jumped over using next().

See also value().

pub unsafe fn new(
    value: impl CastInto<Ref<QJSValue>>
) -> CppBox<QJSValueIterator>
[src]

Constructs an iterator for traversing object. The iterator is set to be at the front of the sequence of properties (before the first property).

Calls C++ function: [constructor] void QJSValueIterator::QJSValueIterator(const QJSValue& value).

C++ documentation:

Constructs an iterator for traversing object. The iterator is set to be at the front of the sequence of properties (before the first property).

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

Advances the iterator by one position. Returns true if there was at least one item ahead of the iterator (i.e. the iterator was not already at the back of the property sequence); otherwise returns false.

Calls C++ function: bool QJSValueIterator::next().

C++ documentation:

Advances the iterator by one position. Returns true if there was at least one item ahead of the iterator (i.e. the iterator was not already at the back of the property sequence); otherwise returns false.

See also hasNext() and name().

pub unsafe fn value(&self) -> CppBox<QJSValue>[src]

Returns the value of the last property that was jumped over using next().

Calls C++ function: QJSValue QJSValueIterator::value() const.

C++ documentation:

Returns the value of the last property that was jumped over using next().

See also name().

Trait Implementations

impl CppDeletable for QJSValueIterator[src]

unsafe fn delete(&self)[src]

Destroys the iterator.

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

C++ documentation:

Destroys the iterator.

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.