このページでは

QJsonArray::iterator Class

class QJsonArray::iterator

QJsonArray::iterator クラスは、QJsonArray に対してSTLスタイルの非constイテレータを提供します。詳細...

QJsonArray::iterator の比較

カテゴリ比較可能な型
strongQJsonArray::iterator
strongQJsonArray::const_iterator.

パブリック型

パブリック関数

iterator()
iterator(const QJsonArray::iterator &other)
QJsonValueRef operator*() const
QJsonArray::iterator operator+(qsizetype j) const
QJsonArray::iterator &operator++()
QJsonArray::iterator operator++(int)
QJsonArray::iterator &operator+=(qsizetype j)
qsizetype operator-(QJsonArray::iterator other) const
QJsonArray::iterator operator-(qsizetype j) const
QJsonArray::iterator &operator--()
QJsonArray::iterator operator--(int)
QJsonArray::iterator &operator-=(qsizetype j)
const QJsonValueConstRef *operator->() const
QJsonValueRef operator[](qsizetype j) const
bool operator!=(const QJsonArray::iterator &lhs, const QJsonArray::const_iterator &rhs)
bool operator!=(const QJsonArray::iterator &lhs, const QJsonArray::iterator &rhs)
bool operator<(const QJsonArray::iterator &lhs, const QJsonArray::const_iterator &rhs)
bool operator<(const QJsonArray::iterator &lhs, const QJsonArray::iterator &rhs)
bool operator<=(const QJsonArray::iterator &lhs, const QJsonArray::const_iterator &rhs)
bool operator<=(const QJsonArray::iterator &lhs, const QJsonArray::iterator &rhs)
bool operator==(const QJsonArray::iterator &lhs, const QJsonArray::const_iterator &rhs)
bool operator==(const QJsonArray::iterator &lhs, const QJsonArray::iterator &rhs)
bool operator>(const QJsonArray::iterator &lhs, const QJsonArray::const_iterator &rhs)
bool operator>(const QJsonArray::iterator &lhs, const QJsonArray::iterator &rhs)
bool operator>=(const QJsonArray::iterator &lhs, const QJsonArray::const_iterator &rhs)
bool operator>=(const QJsonArray::iterator &lhs, const QJsonArray::iterator &rhs)

詳細な説明

QJsonArray::iterator QJsonArray を反復処理し、イテレータに関連付けられた配列要素を変更することができます。const を反復処理したい場合は、代わりに を使用してください。イテレータを介して を変更する必要がない限り、非constの に対しても を使用するのが一般的なベストプラクティスです。constイテレータは処理速度がわずかに速く、コードの可読性も向上します。QJsonArray QJsonArray::const_iterator QJsonArray QJsonArray QJsonArray::const_iterator

QJsonArray::iterator のデフォルトコンストラクタは、初期化されていないイテレータを作成します。反復処理を開始する前に、QJsonArray::begin()、QJsonArray::end()、またはQJsonArray::insert()などのQJsonArray 関数を使用して、イテレータを初期化する必要があります。

ほとんどの `QJsonArray ` 関数は、イテレータではなく整数のインデックスを受け取ります。そのため、QJsonArray に関連してイテレータが役立つことはほとんどありません。STL スタイルのイテレータが意味をなす場面の一つは、generic algorithms の引数として使用する場合です。

同じ配列に対して複数のイテレータを使用することができます。ただし、QJsonArray に対して非 const の関数呼び出しを行うと、既存のすべてのイテレータが未定義の状態になることに注意してください。

QJsonArray::const_iteratorも参照してください 。

メンバ型のドキュメント

iterator::iterator_category

このイテレータがランダムアクセスイテレータであることを示す、std::random_access_iterator_tagの同義語。

メンバ関数のドキュメント

iterator::iterator()

初期化されていないイテレータを作成します。

初期化されていないイテレータに対して、operator*() や operator++() などの関数を呼び出してはなりません。使用する前に、operator=() を使用して値を代入してください。

QJsonArray::begin() およびQJsonArray::end()も参照してください 。

[constexpr noexcept default] iterator::iterator(const QJsonArray::iterator &other)

iterator のインスタンスをコピーして生成します。

QJsonValueRef iterator::operator*() const

現在の項目に対する変更可能な参照を返します。

代入文の左辺で演算子*()を使用することで、項の値を変更できます。

戻り値の型はQJsonValueRef です。これはQJsonArray およびQJsonObject のヘルパークラスです。QJsonValueRef 型のオブジェクトを取得した場合、それをQJsonValue への参照であるかのように使用できます。これに代入を行うと、その代入は、参照を取得したQJsonObject のQJsonArray にある文字に対して適用されます。

QJsonArray::iterator iterator::operator+(qsizetype j) const

このイテレータからj の位置だけ先にある項目へのイテレータを返します。j が負の値の場合、イテレータは後ろ方向に移動します。

operator-() およびoperator+=()も参照してください 。

QJsonArray::iterator &iterator::operator++()

プレフィックス演算子 `++ `(++it )は、イテレータを配列内の次の要素に進め、新しい現在の要素へのイテレータを返します。

QJsonArray::end() に対してこの関数を呼び出すと、未定義の結果となります。

operator--()も参照してください 。

QJsonArray::iterator iterator::operator++(int)

後置演算子++ (it++ )は、イテレータを配列内の次の要素へと進め、直前の要素へのイテレータを返します。

これはオーバーロードされた関数です。

QJsonArray::iterator &iterator::operator+=(qsizetype j)

イテレータをj 個分進めます。j が負の場合、イテレータは後退します。

operator-=() およびoperator+()も参照してください 。

qsizetype iterator::operator-(QJsonArray::iterator other) const

other が指す項目と、このイテレータが指す項目の間の項目の数を返します。

QJsonArray::iterator iterator::operator-(qsizetype j) const

このイテレータからj の位置分だけ後ろにある項目へのイテレータを返します。j が負の値の場合、イテレータは前方へ移動します。

operator+() およびoperator-=()も参照してください 。

QJsonArray::iterator &iterator::operator--()

接頭辞演算子 `-- `(--it )は、先行する要素を現在の要素として設定し、新しい現在の要素へのイテレータを返します。

QJsonArray::begin() に対してこの関数を呼び出すと、未定義の結果となります。

operator++()も参照してください 。

QJsonArray::iterator iterator::operator--(int)

後置演算子「-- 」(it-- )は、直前の要素を現在の要素とし、それ以前に現在の要素だった要素へのイテレータを返します。

これはオーバーロードされた関数です。

QJsonArray::iterator &iterator::operator-=(qsizetype j)

イテレータをj 個分戻します。j が負の値の場合、イテレータは前進します。

operator+=() およびoperator-()も参照してください 。

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

現在の項目への変更可能な参照へのポインタを返します。

QJsonValueRef iterator::operator[](qsizetype j) const

このイテレータが指す項目(位置*this + j にある項目)のうち、オフセットj にある項目への、変更可能な参照を返します。

この関数は、QJsonArray イテレータが C++ のポインタのように動作するようにするために提供されています。

戻り値の型はQJsonValueRef であり、これはQJsonArray およびQJsonObject のヘルパークラスです。QJsonValueRef 型のオブジェクトを取得すると、それをQJsonValue への参照であるかのように使用できます。これに代入を行うと、その代入は、参照を取得したQJsonArray またはQJsonObject 内の要素に適用されます。

operator+()も参照してください 。

関連する非メンバー

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

[noexcept] bool operator!=(const QJsonArray::iterator &lhs, const QJsonArray::iterator &rhs)

lhs がrhs のイテレータとは異なる項目を指している場合はtrue を返し、そうでない場合はfalse を返します。

operator==()も参照してください 。

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

[noexcept] bool operator<(const QJsonArray::iterator &lhs, const QJsonArray::iterator &rhs)

lhs イテレータが指す項目が、rhs イテレータが指す項目よりも小さい場合、true を返します。

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

[noexcept] bool operator<=(const QJsonArray::iterator &lhs, const QJsonArray::iterator &rhs)

lhs イテレータが指す項目が、rhs イテレータが指す項目以下である場合、true を返します。

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

[noexcept] bool operator==(const QJsonArray::iterator &lhs, const QJsonArray::iterator &rhs)

lhs がrhs イテレータと同じ項目を指している場合はtrue を返し、そうでない場合はfalse を返します。

operator!=()も参照してください 。

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

[noexcept] bool operator>(const QJsonArray::iterator &lhs, const QJsonArray::iterator &rhs)

lhs イテレータが指す項目が、rhs イテレータが指す項目よりも大きい場合、true を返します。

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

[noexcept] bool operator>=(const QJsonArray::iterator &lhs, const QJsonArray::iterator &rhs)

lhs イテレータが指す項目が、rhs イテレータが指す項目以上である場合、true を返します。

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