QJsonObject::iterator Class
class QJsonObject::iteratorLa classe ` QJsonObject::iterator ` fornisce un iteratore non costante in stile STL per ` QJsonObject`. Maggiori informazioni...
- Elenco di tutti i membri, compresi quelli ereditati
- L'iteratore fa parte del supporto JSON in Qt.
Confronto tra QJsonObject::iterator
| Categoria | Tipi comparabili |
|---|---|
| forte | QJsonObject::iterator |
| strong | QJsonObject::const_iterator. |
Tipi pubblici
Funzioni pubbliche
| iterator() | |
| iterator(const QJsonObject::iterator &other) | |
| QString | key() const |
(since 6.10) QAnyStringView | keyView() const |
| QJsonValueRef | value() const |
| QJsonValueRef | operator*() const |
| QJsonObject::iterator | operator+(qsizetype j) const |
| QJsonObject::iterator & | operator++() |
| QJsonObject::iterator | operator++(int) |
| QJsonObject::iterator & | operator+=(qsizetype j) |
| qsizetype | operator-(QJsonObject::iterator other) const |
| QJsonObject::iterator | operator-(qsizetype j) const |
| QJsonObject::iterator & | operator--() |
| QJsonObject::iterator | operator--(int) |
| QJsonObject::iterator & | operator-=(qsizetype j) |
| QJsonValueRef * | operator->() |
| const QJsonValueConstRef * | operator->() const |
| QJsonValueRef | operator[](qsizetype j) const |
Elementi non membri correlati
| bool | operator!=(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs) |
| bool | operator!=(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs) |
| bool | operator<(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs) |
| bool | operator<(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs) |
| bool | operator<=(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs) |
| bool | operator<=(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs) |
| bool | operator==(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs) |
| bool | operator==(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs) |
| bool | operator>(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs) |
| bool | operator>(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs) |
| bool | operator>=(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs) |
| bool | operator>=(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs) |
Descrizione dettagliata
QJsonObject::iterator consente di iterare su un oggetto ` QJsonObject ` e di modificare il valore (ma non la chiave) memorizzato sotto una determinata chiave. Se si desidera iterare su un `const QJsonObject`, è necessario utilizzare ` QJsonObject::const_iterator`. È generalmente buona pratica utilizzare ` QJsonObject::const_iterator ` anche su un `non-const QJsonObject `, a meno che non sia necessario modificare l'QJsonObject tramite l'iteratore. Gli iteratori `const` sono leggermente più veloci e migliorano la leggibilità del codice.
Il costruttore predefinito QJsonObject::iterator crea un iteratore non inizializzato. È necessario inizializzarlo utilizzando una funzione QJsonObject come QJsonObject::begin(), QJsonObject::end() o QJsonObject::find() prima di poter iniziare l’iterazione.
È possibile utilizzare più iteratori sullo stesso oggetto. Tuttavia, gli iteratori esistenti diventeranno "dangling" una volta che l'oggetto verrà modificato.
Vedi anche QJsonObject::const_iterator, Supporto JSON in Qt e Salvataggio e caricamento di un gioco.
Documentazione sui tipi dei membri
iterator::iterator_category
Sinonimo di std::random_access_iterator_tag che indica che questo iteratore è un iteratore ad accesso casuale.
Nota: Nelle versioni di Qt precedenti alla 5.6, questo valore era stato impostato per errore su std::bidirectional_iterator_tag.
Documentazione delle funzioni membro
iterator::iterator()
Crea un iteratore non inizializzato.
Funzioni come key(), value() e l'operatore++() non devono essere chiamate su un iteratore non inizializzato. Utilizzare l'operatore=() per assegnargli un valore prima di utilizzarlo.
Vedi anche QJsonObject::begin() e QJsonObject::end().
[constexpr noexcept default] iterator::iterator(const QJsonObject::iterator &other)
Crea una copia di un'istanza di ` iterator`.
QString iterator::key() const
Restituisce la chiave dell'elemento corrente.
Non esiste un modo diretto per modificare la chiave di un elemento tramite un iteratore, sebbene sia possibile farlo chiamando QJsonObject::erase() seguito da QJsonObject::insert().
Vedi anche value() e keyView().
[since 6.10] QAnyStringView iterator::keyView() const
Restituisce la chiave dell'elemento corrente come oggetto ` QAnyStringView`. Questa funzione non alloca memoria.
Poiché ` QJsonObject ` memorizza le chiavi in US-ASCII, UTF-8 o UTF-16, l'oggetto ` QAnyStringView ` restituito può essere in una qualsiasi di queste codifiche.
Non esiste un modo diretto per modificare la chiave di un elemento tramite un iteratore, sebbene ciò sia possibile chiamando ` QJsonObject::erase()` seguito da ` QJsonObject::insert()`.
Questa funzione è stata introdotta in Qt 6.10.
QJsonValueRef iterator::value() const
Restituisce un riferimento modificabile al valore dell'elemento corrente.
È possibile modificare il valore di un elemento utilizzando la funzione `value()` sul lato sinistro di un'assegnazione.
Il valore restituito è di tipo ` QJsonValueRef`, una classe di supporto per ` QJsonArray ` e ` QJsonObject`. Quando si ottiene un oggetto di tipo ` QJsonValueRef`, è possibile utilizzarlo come se fosse un riferimento a un ` QJsonValue`. Se gli si assegna un valore, l'assegnazione si applicherà all'elemento contenuto in ` QJsonArray ` o ` QJsonObject ` da cui è stato ottenuto il riferimento.
Vedi anche key(), keyView() e operator*().
QJsonValueRef iterator::operator*() const
Restituisce un riferimento modificabile al valore dell'elemento corrente.
Equivalente a ` value()`.
Il valore restituito è di tipo QJsonValueRef, una classe di supporto per QJsonArray e QJsonObject. Quando si ottiene un oggetto di tipo QJsonValueRef, è possibile utilizzarlo come se fosse un riferimento a un QJsonValue. Se gli si assegna un valore, l'assegnazione si applicherà all'elemento contenuto in QJsonArray o QJsonObject da cui è stato ottenuto il riferimento.
QJsonObject::iterator iterator::operator+(qsizetype j) const
Restituisce un iteratore che punta all'elemento situato a j posizioni in avanti rispetto a questo iteratore. Se j è negativo, l'iteratore si sposta all'indietro.
Vedi anche operator-().
QJsonObject::iterator &iterator::operator++()
L'operatore con prefisso ++, ++i, fa avanzare l'iteratore all'elemento successivo dell'oggetto e restituisce un iteratore puntante al nuovo elemento corrente.
La chiamata a questa funzione su QJsonObject::end() produce risultati indefiniti.
Vedi anche operator--().
QJsonObject::iterator iterator::operator++(int)
L'operatore postfisso ++, i++, fa avanzare l'iteratore all'elemento successivo dell'oggetto e restituisce un iteratore all'elemento precedentemente corrente.
Si tratta di una funzione sovraccaricata.
QJsonObject::iterator &iterator::operator+=(qsizetype j)
Fai avanzare l’iteratore di j elementi. Se j è negativo, l’iteratore va all’indietro.
Vedi anche operator-=() e operator+().
qsizetype iterator::operator-(QJsonObject::iterator other) const
Restituisce il numero di elementi compresi tra l'elemento indicato dall'other e e quello indicato da questo iteratore.
QJsonObject::iterator iterator::operator-(qsizetype j) const
Restituisce un iteratore che punta all'elemento situato a j posizioni indietro rispetto a questo iteratore. Se j è negativo, l'iteratore procede in avanti.
Vedi anche operator+().
QJsonObject::iterator &iterator::operator--()
L'operatore prefissato --, --i, imposta l'elemento precedente come corrente e restituisce un iteratore che punta al nuovo elemento corrente.
La chiamata a questa funzione su QJsonObject::begin() produce risultati indefiniti.
Vedi anche operator++().
QJsonObject::iterator iterator::operator--(int)
L'operatore postfisso --, i--, rende l'elemento precedente l'elemento corrente e restituisce un iteratore che punta all'elemento che era precedentemente corrente.
Si tratta di una funzione sovraccaricata.
QJsonObject::iterator &iterator::operator-=(qsizetype j)
Fa tornare indietro l'iteratore di j elementi. Se j è negativo, l'iteratore va avanti.
Vedi anche operator+=() e operator-().
QJsonValueRef *iterator::operator->()
Restituisce un puntatore a un riferimento modificabile all'elemento corrente.
const QJsonValueConstRef *iterator::operator->() const
Restituisce un puntatore a un riferimento costante all'elemento corrente.
QJsonValueRef iterator::operator[](qsizetype j) const
Restituisce un riferimento modificabile all'elemento situato all'offset j a partire dall'elemento indicato da questo iteratore (l'elemento in posizione *this + j).
Questa funzione è fornita per far sì che gli iteratori QJsonObject si comportino come puntatori C++.
Il valore restituito è di tipo QJsonValueRef, una classe di supporto per QJsonArray e QJsonObject. Quando si ottiene un oggetto di tipo QJsonValueRef, è possibile utilizzarlo come se fosse un riferimento a un QJsonValue. Se gli si assegna un valore, l'assegnazione si applicherà all'elemento contenuto in QJsonArray o QJsonObject da cui è stato ottenuto il riferimento.
Vedi anche operator+().
Elementi non membri correlati
[noexcept] bool operator!=(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs)
[noexcept] bool operator!=(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs)
Restituisce ` true ` se ` lhs ` punta a un elemento diverso dall'iteratore ` rhs `; altrimenti restituisce ` false`.
Vedi anche operator==().
[noexcept] bool operator<(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs)
[noexcept] bool operator<(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs)
Restituisce ` true ` se l'elemento a cui punta l'iteratore ` lhs ` è minore dell'elemento a cui punta l'iteratore ` rhs `.
[noexcept] bool operator<=(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs)
[noexcept] bool operator<=(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs)
Restituisce ` true ` se l'elemento indicato dall'iteratore ` lhs ` è minore o uguale all'elemento indicato dall'iteratore ` rhs `.
[noexcept] bool operator==(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs)
[noexcept] bool operator==(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs)
Restituisce ` true ` se ` lhs ` punta allo stesso elemento dell’iteratore ` rhs `; altrimenti restituisce ` false`.
Vedi anche operator!=().
[noexcept] bool operator>(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs)
[noexcept] bool operator>(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs)
Restituisce " true " se l'elemento a cui punta l'iteratore lhs è maggiore dell'elemento a cui punta l'iteratore rhs.
[noexcept] bool operator>=(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs)
[noexcept] bool operator>=(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs)
Restituisce ` true ` se l'elemento indicato dall'iteratore ` lhs ` è maggiore o uguale all'elemento indicato dall'iteratore ` rhs `.
© 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.