QJSValueIterator Class

QJSValueIterator 클래스는 QJSValue 에 대한 Java 스타일 이터레이터를 제공합니다. 더 보기...

Header: #include <QJSValueIterator>
CMake: find_package(Qt6 REQUIRED COMPONENTS Qml)
target_link_libraries(mytarget PRIVATE Qt6::Qml)
qmake: QT += qml

공용 함수

QJSValueIterator(const QJSValue &object)
~QJSValueIterator()
bool hasNext() const
QString name() const
bool next()
QJSValue value() const
QJSValueIterator &operator=(QJSValue &object)

상세 설명

QJSValueIterator 생성자는 QJSValue 를 인수로 받습니다. 생성 후 이터레이터는 속성 시퀀스의 맨 처음에 위치합니다. QJSValue 의 모든 프로퍼티를 반복하는 방법은 다음과 같습니다:

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

next()는 반복기를 전진시킵니다. name () 및 value() 함수는 마지막으로 건너뛴 항목의 이름과 값을 반환합니다.

QJSValueIterator는 QJSValue 의 자체 속성만 반복하므로 프로토타입 체인을 따르지 않는다는 점에 유의하세요. 이와 같은 루프를 사용하여 프로토타입 체인을 따라갈 수 있습니다:

QJSValue obj = ...; // 반복할 객체동안 (obj.isObject()) {.  QJSValueIterator it(obj); while (it.hasNext()) { it.next();        qDebug() << it.name();
    객체 = 객체.프로토타입(); }

QJSValue::property()도 참조하세요 .

멤버 함수 문서

QJSValueIterator::QJSValueIterator(const QJSValue &object)

object 을 트래버스하기 위한 이터레이터를 구축합니다. 이터레이터는 프로퍼티 시퀀스의 맨 앞(첫 번째 프로퍼티 앞)에 위치하도록 설정됩니다.

[noexcept] QJSValueIterator::~QJSValueIterator()

이터레이터를 파괴합니다.

bool QJSValueIterator::hasNext() const

반복자 앞에 항목이 하나 이상 있는 경우(즉, 반복자가 속성 시퀀스의 뒤에 있지 않은 경우) 참을 반환하고, 그렇지 않으면 거짓을 반환합니다.

next()도 참조하세요 .

QString QJSValueIterator::name() const

next()를 사용하여 마지막으로 건너뛴 프로퍼티의 이름을 반환합니다.

value()도 참조하세요 .

bool QJSValueIterator::next()

이터레이터를 한 위치 전진시킵니다. 반복자 앞에 항목이 하나 이상 있는 경우(즉, 반복자가 속성 시퀀스의 뒤에 있지 않은 경우) 참을 반환하고, 그렇지 않으면 거짓을 반환합니다.

hasNext() 및 name()도 참조하세요 .

QJSValue QJSValueIterator::value() const

next()를 사용하여 마지막으로 건너뛴 프로퍼티의 값을 반환합니다.

name()도 참조하세요 .

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

반복자가 object 에서 작동하도록 합니다. 이터레이터는 프로퍼티 시퀀스의 앞쪽(첫 번째 프로퍼티 앞)에 위치하도록 설정됩니다.

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.