Auf dieser Seite

QJsonObject::const_iterator Class

class QJsonObject::const_iterator

Die Klasse „ QJsonObject::const_iterator “ stellt einen const-Iterator im STL-Stil für „ QJsonObject “ bereit. Mehr...

QJsonObject::const_iterator – Vergleiche

KategorieVergleichbare Typen
starkQJsonObject::const_iterator
strongQJsonObject::iterator.

Öffentliche Typen

Öffentliche Funktionen

const_iterator()
const_iterator(const QJsonObject::iterator &other)
const_iterator(const QJsonObject::const_iterator &other)
QString key() const
(since 6.10) QAnyStringView keyView() const
QJsonValueConstRef value() const
const QJsonValueConstRef operator*() const
QJsonObject::const_iterator operator+(qsizetype j) const
QJsonObject::const_iterator &operator++()
QJsonObject::const_iterator operator++(int)
QJsonObject::const_iterator &operator+=(qsizetype j)
qsizetype operator-(QJsonObject::const_iterator other) const
QJsonObject::const_iterator operator-(qsizetype j) const
QJsonObject::const_iterator &operator--()
QJsonObject::const_iterator operator--(int)
QJsonObject::const_iterator &operator-=(qsizetype j)
const QJsonValueConstRef *operator->() const
QJsonValueConstRef operator[](qsizetype j) const
bool operator!=(const QJsonObject::const_iterator &lhs, const QJsonObject::const_iterator &rhs)
bool operator<(const QJsonObject::const_iterator &lhs, const QJsonObject::const_iterator &rhs)
bool operator<=(const QJsonObject::const_iterator &lhs, const QJsonObject::const_iterator &rhs)
bool operator==(const QJsonObject::const_iterator &lhs, const QJsonObject::const_iterator &rhs)
bool operator>(const QJsonObject::const_iterator &lhs, const QJsonObject::const_iterator &rhs)
bool operator>=(const QJsonObject::const_iterator &lhs, const QJsonObject::const_iterator &rhs)

Ausführliche Beschreibung

QJsonObject::const_iterator ermöglicht es Ihnen, einen ` QJsonObject` zu durchlaufen. Wenn Sie den ` QJsonObject ` während des Durchlaufens ändern möchten, müssen Sie stattdessen ` QJsonObject::iterator ` verwenden. Es empfiehlt sich generell, auch bei einem nicht-konstanten ` QJsonObject ` ` QJsonObject::const_iterator ` zu verwenden, es sei denn, Sie müssen den ` QJsonObject ` über den Iterator ändern. Konstante Iteratoren sind etwas schneller und verbessern die Lesbarkeit des Codes.

Der Standardkonstruktor QJsonObject::const_iterator erstellt einen nicht initialisierten Iterator. Sie müssen ihn mit einer QJsonObject -Funktion wie QJsonObject::constBegin(), QJsonObject::constEnd() oder QJsonObject::find() initialisieren, bevor Sie mit der Iteration beginnen können.

Für dasselbe Objekt können mehrere Iteratoren verwendet werden. Bereits vorhandene Iteratoren werden jedoch ungültig, wenn das Objekt geändert wird.

Siehe auch „ QJsonObject::iterator“ , „JSON-Unterstützung in Qt“ und „Speichern und Laden eines Spiels“.

Dokumentation zu Mitgliedstypen

const_iterator::iterator_category

Ein Synonym für „std::random_access_iterator_tag“, das angibt, dass es sich bei diesem Iterator um einen Random-Access-Iterator handelt.

Hinweis: In Qt-Versionen vor 5.6 wurde dies versehentlich auf „std::bidirectional_iterator_tag“ gesetzt.

Dokumentation der Mitgliedsfunktionen

const_iterator::const_iterator()

Erstellt einen nicht initialisierten Iterator.

Funktionen wie ` key()`, ` value()` und der Operator `++()` dürfen nicht für einen nicht initialisierten Iterator aufgerufen werden. Verwenden Sie den Operator `=()`, um ihm vor der Verwendung einen Wert zuzuweisen.

Siehe auch ` QJsonObject::constBegin()` und ` QJsonObject::constEnd()`.

const_iterator::const_iterator(const QJsonObject::iterator &other)

Erstellt eine Kopie von „ other “.

[constexpr noexcept default] const_iterator::const_iterator(const QJsonObject::const_iterator &other)

Erstellt eine Instanz von „ const_iterator “ durch Kopieren.

QString const_iterator::key() const

Gibt den Schlüssel des aktuellen Elements zurück.

Siehe auch value() und keyView().

[since 6.10] QAnyStringView const_iterator::keyView() const

Gibt den Schlüssel des aktuellen Elements als ` QAnyStringView` zurück. Diese Funktion führt keine Speicherzuweisung durch.

Da ` QJsonObject ` Schlüssel in US-ASCII, UTF-8 oder UTF-16 speichert, kann der zurückgegebene ` QAnyStringView ` in einer dieser Kodierungen vorliegen.

Diese Funktion wurde in Qt 6.10 eingeführt.

Siehe auch ` value()` und ` key()`.

QJsonValueConstRef const_iterator::value() const

Gibt den Wert des aktuellen Elements zurück.

Siehe auch key(), keyView() und operator*().

const QJsonValueConstRef const_iterator::operator*() const

Gibt den Wert des aktuellen Elements zurück.

Entspricht „ value()“.

Siehe auch „ key()“ und „ keyView()“.

QJsonObject::const_iterator const_iterator::operator+(qsizetype j) const

Gibt einen Iterator für das Element zurück, das sich „ j “ Positionen vor diesem Iterator befindet. Ist „ j “ negativ, bewegt sich der Iterator rückwärts.

Bei großen Werten für ` j ` kann diese Operation langsam sein.

Siehe auch operator-().

QJsonObject::const_iterator &const_iterator::operator++()

Der Präfixoperator „ ++ “, ++i, springt mit dem Iterator zum nächsten Element des Objekts und gibt einen Iterator auf das neue aktuelle Element zurück.

Der Aufruf dieser Funktion auf ` QJsonObject::end()` führt zu undefinierten Ergebnissen.

Siehe auch operator--().

QJsonObject::const_iterator const_iterator::operator++(int)

Der Postfix-Operator „ ++ “ ( i++) verschiebt den Iterator zum nächsten Element des Objekts und gibt einen Iterator auf das zuvor aktuelle Element zurück.

Dies ist eine überladene Funktion.

QJsonObject::const_iterator &const_iterator::operator+=(qsizetype j)

Bewegt den Iterator um j Elemente weiter. Ist j negativ, bewegt sich der Iterator rückwärts.

Bei großen Werten für „ j “ kann dieser Vorgang langsam sein.

Siehe auch „ operator-=()“ und „ operator+()“.

qsizetype const_iterator::operator-(QJsonObject::const_iterator other) const

Gibt die Anzahl der Elemente zwischen dem Element zurück, auf das „ other “ verweist, und dem Element, auf das dieser Iterator verweist.

QJsonObject::const_iterator const_iterator::operator-(qsizetype j) const

Gibt einen Iterator für das Element zurück, das sich j Positionen rückwärts von diesem Iterator befindet. Ist j negativ, bewegt sich der Iterator vorwärts.

Bei großen Werten für ` j ` kann diese Operation langsam sein.

Siehe auch ` operator+()`.

QJsonObject::const_iterator &const_iterator::operator--()

Der Präfixoperator „ -- “, --i, macht das vorhergehende Element zum aktuellen Element und gibt einen Iterator zurück, der auf das neue aktuelle Element verweist.

Der Aufruf dieser Funktion auf ` QJsonObject::begin()` führt zu undefinierten Ergebnissen.

Siehe auch ` operator++()`.

QJsonObject::const_iterator const_iterator::operator--(int)

Der Postfix-Operator „ -- “ ( i--) macht das vorangehende Element zum aktuellen Element und gibt einen Iterator zurück, der auf das zuvor aktuelle Element verweist.

Dies ist eine überladene Funktion.

QJsonObject::const_iterator &const_iterator::operator-=(qsizetype j)

Bewegt den Iterator um j Elemente zurück. Ist j negativ, bewegt sich der Iterator vorwärts.

Bei großen Werten für „ j “ kann dieser Vorgang langsam sein.

Siehe auch ` operator+=()` und ` operator-()`.

const QJsonValueConstRef *const_iterator::operator->() const

Gibt einen Zeiger auf das aktuelle Element zurück.

QJsonValueConstRef const_iterator::operator[](qsizetype j) const

Gibt das Element am Offset j aus dem Element zurück, auf das dieser Iterator zeigt (das Element an der Position *this + j).

Diese Funktion wird bereitgestellt, damit sich QJsonObject -Iteratoren wie C++-Zeiger verhalten.

Siehe auch operator+().

Verwandte Nicht-Mitglieder

[noexcept] bool operator!=(const QJsonObject::const_iterator &lhs, const QJsonObject::const_iterator &rhs)

Gibt „ true “ zurück, wenn „ lhs “ auf ein anderes Element verweist als der Iterator „ rhs “; andernfalls wird „ false “ zurückgegeben.

Siehe auch operator==().

[noexcept] bool operator<(const QJsonObject::const_iterator &lhs, const QJsonObject::const_iterator &rhs)

Gibt ` true ` zurück, wenn das Element, auf das der Iterator ` lhs ` verweist, kleiner ist als das Element, auf das der Iterator ` rhs ` verweist.

[noexcept] bool operator<=(const QJsonObject::const_iterator &lhs, const QJsonObject::const_iterator &rhs)

Gibt „ true “ zurück, wenn das Element, auf das der Iterator „ lhs “ verweist, kleiner oder gleich dem Element ist, auf das der Iterator „ rhs “ verweist.

[noexcept] bool operator==(const QJsonObject::const_iterator &lhs, const QJsonObject::const_iterator &rhs)

Gibt „ true “ zurück, wenn „ lhs “ auf dasselbe Element verweist wie der Iterator „ rhs “; andernfalls wird „ false “ zurückgegeben.

Siehe auch operator!=().

[noexcept] bool operator>(const QJsonObject::const_iterator &lhs, const QJsonObject::const_iterator &rhs)

Gibt „ true “ zurück, wenn das Element, auf das der Iterator „ lhs “ verweist, größer ist als das Element, auf das der Iterator „ rhs “ verweist.

[noexcept] bool operator>=(const QJsonObject::const_iterator &lhs, const QJsonObject::const_iterator &rhs)

Gibt „ true “ zurück, wenn das Element, auf das der Iterator „ lhs “ verweist, größer oder gleich dem Element ist, auf das der Iterator „ rhs “ verweist.

© 2026 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.