aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc/snippets/code/src_script_qjsvalueiterator.cpp
blob: 9316317c40a8f269ed21d861aae5f226dad53f91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

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


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