IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QJSValueIterator Class

The https:// class provides a Java-style iterator for https://.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QJSValueIterator Class▲

  • Header: QJSValueIterator

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS Qml)

    target_link_libraries(mytarget PRIVATE Qt6::Qml)

  • qmake: QT += qml

  • Group: QJSValueIterator is part of qtjavascript

Detailed Description▲

The https:// constructor takes a https:// 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 https://:

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

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

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

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

See Also▲

See also QJSValue::property()

Member Function Documentation▲

 

QJSValueIterator::QJSValueIterator(const QJSValue &object)▲

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

QJSValueIterator::~QJSValueIterator()▲

Destroys the iterator.

bool QJSValueIterator::hasNext() const▲

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▲

See also https://()

QString QJSValueIterator::name() const▲

Returns the name of the last property that was jumped over using https://().

See Also▲

See also https://()

bool QJSValueIterator::next()▲

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▲

See also https://(), https://()

QJSValue QJSValueIterator::value() const▲

Returns the value of the last property that was jumped over using https://().

See Also▲

See also https://()

QJSValueIterator &QJSValueIterator::operator=(QJSValue &object)▲

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

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+   

Ce document est disponible sous la licence https:// telle que publiée par la Free Software Foundation.