このページでは

QPersistentModelIndex Class

QPersistentModelIndex クラスは、データモデル内のデータを検索するために使用されます。詳細...

ヘッダー: #include <QPersistentModelIndex>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core

QPersistentModelIndex の比較

カテゴリ比較可能な型
strongQPersistentModelIndex
strongQModelIndex.

パブリック関数

QPersistentModelIndex(const QModelIndex &index)
QPersistentModelIndex(const QPersistentModelIndex &other)
QPersistentModelIndex(QPersistentModelIndex &&other)
int column() const
QVariant data(int role = Qt::DisplayRole) const
Qt::ItemFlags flags() const
bool isValid() const
const QAbstractItemModel *model() const
(since 6.0) void multiData(QModelRoleDataSpan roleDataSpan) const
QModelIndex parent() const
int row() const
QModelIndex sibling(int row, int column) const
void swap(QPersistentModelIndex &other)
operator QModelIndex() const
QPersistentModelIndex &operator=(QPersistentModelIndex &&other)
QPersistentModelIndex &operator=(const QModelIndex &other)
QPersistentModelIndex &operator=(const QPersistentModelIndex &other)
size_t qHash(const QPersistentModelIndex &key, size_t seed = 0)
bool operator!=(const QPersistentModelIndex &lhs, const QModelIndex &rhs)
bool operator!=(const QPersistentModelIndex &lhs, const QPersistentModelIndex &rhs)
bool operator<(const QPersistentModelIndex &lhs, const QPersistentModelIndex &rhs)
bool operator==(const QPersistentModelIndex &lhs, const QModelIndex &rhs)
bool operator==(const QPersistentModelIndex &lhs, const QPersistentModelIndex &rhs)

詳細な説明

QPersistentModelIndex は、アプリケーションによって保存され、後でモデル内の情報にアクセスするために使用できるモデルインデックスです。QModelIndex クラスとは異なり、モデルがアイテムへの参照がモデルからアクセス可能な限り有効であり続けることを保証するため、QPersistentModelIndex を保存しても安全です。

永続モデルインデックスを使用する前に、その有効性を確認することをお勧めします。

注: QStandardItemModel のQPersistentModelIndexを、モデルのアイテムの1つに保存することは できません。

「Model/View プログラミング」、「QModelIndex 」、および「QAbstractItemModel 」も参照してください 。

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

QPersistentModelIndex::QPersistentModelIndex(const QModelIndex &index)

モデル `index` のコピーである新しい `QPersistentModelIndex` を作成します。

QPersistentModelIndex::QPersistentModelIndex(const QPersistentModelIndex &other)

other の永続モデルインデックスのコピーとなる、新しいQPersistentModelIndexを作成します。

[noexcept] QPersistentModelIndex::QPersistentModelIndex(QPersistentModelIndex &&other)

QPersistentModelIndexのインスタンスをムーブコンストラクタで生成し、other が指していたのと同じオブジェクトを指すようにします。

int QPersistentModelIndex::column() const

この永続モデルインデックスが参照するカラムを返します。

QVariant QPersistentModelIndex::data(int role = Qt::DisplayRole) const

指定されたrole の、インデックスが指す項目のデータを返します。ただし、この永続モデルインデックスがinvalid である場合は、デフォルトで生成されたQVariant を返します。

Qt::ItemDataRole およびQAbstractItemModel::setData()も参照してください 。

Qt::ItemFlags QPersistentModelIndex::flags() const

インデックスで指定された項目のフラグを返します。

bool QPersistentModelIndex::isValid() const

この永続モデルインデックスが有効な場合は `true ` を返し、そうでない場合は `false` を返します。

有効なインデックスはモデルに属し、行番号と列番号が非負である。

model()、row()、およびcolumn()も参照してください 。

const QAbstractItemModel *QPersistentModelIndex::model() const

そのインデックスが属するモデルを返します。

[since 6.0] void QPersistentModelIndex::multiData(QModelRoleDataSpan roleDataSpan) const

インデックスで指定された項目について、指定されたroleDataSpan に値を設定します。

この関数は Qt 6.0 で導入されました。

Qt::ItemDataRole およびQAbstractItemModel::setData()も参照してください 。

QModelIndex QPersistentModelIndex::parent() const

この永続インデックスの親となるQModelIndex を返します。親が存在しない場合は、無効なQModelIndex を返します。

sibling() およびmodel()も参照してください 。

int QPersistentModelIndex::row() const

この永続モデルのインデックスが指す行を返します。

QModelIndex QPersistentModelIndex::sibling(int row, int column) const

row およびcolumn にある兄弟要素を返します。この位置に兄弟要素が存在しない場合は、無効なQModelIndex を返します。

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

[noexcept] void QPersistentModelIndex::swap(QPersistentModelIndex &other)

この永続的なモデルインデックスを「other 」と入れ替えます。この操作は非常に高速で、失敗することはありません。

QPersistentModelIndex::operator QModelIndex() const

QModelIndex を返すキャスト演算子。

[noexcept] QPersistentModelIndex &QPersistentModelIndex::operator=(QPersistentModelIndex &&other)

other をこのQPersistentModelIndex インスタンスに割り当てます。

QPersistentModelIndex &QPersistentModelIndex::operator=(const QModelIndex &other)

永続モデルのインデックスを設定し、other モデルのインデックスと同じモデル内の項目を参照するようにします。

QPersistentModelIndex &QPersistentModelIndex::operator=(const QPersistentModelIndex &other)

永続モデルインデックスを設定し、モデル内のother の永続モデルインデックスと同じ項目を参照するようにします。

関連する非メンバー

[noexcept] size_t qHash(const QPersistentModelIndex &key, size_t seed = 0)

`key` のハッシュ値を、`seed ` を計算のシードとして使用して返します。

[noexcept] bool operator!=(const QPersistentModelIndex &lhs, const QModelIndex &rhs)

lhs の永続モデルインデックスが、rhs のモデルインデックスと同じ場所を指していない場合は、true を返します。それ以外の場合は、false を返します。

[noexcept] bool operator!=(const QPersistentModelIndex &lhs, const QPersistentModelIndex &rhs)

lhs の永続モデルのインデックスがrhs の永続モデルのインデックスと等しくない場合、true を返します。それ以外の場合は、false を返します。

[noexcept] bool operator<(const QPersistentModelIndex &lhs, const QPersistentModelIndex &rhs)

lhs の永続モデルインデックスがrhs の永続モデルインデックスよりも小さい場合はtrue を返し、そうでない場合はfalse を返します。

別の永続モデルインデックスと比較する際には、永続モデルインデックス内の内部データポインタ、行、列、およびモデル値が使用されます。

[noexcept] bool operator==(const QPersistentModelIndex &lhs, const QModelIndex &rhs)

lhs の永続モデルインデックスが、rhs のモデルインデックスと同じ場所を指している場合はtrue を返し、そうでない場合はfalse を返します。

別のモデルインデックスと比較する際には、永続モデルインデックス内の内部データポインタ、行、列、およびモデル値が使用されます。

[noexcept] bool operator==(const QPersistentModelIndex &lhs, const QPersistentModelIndex &rhs)

lhs の永続モデルインデックスがrhs の永続モデルインデックスと等しい場合は、true を返します。そうでない場合は、false を返します。

別の永続モデルインデックスと比較する際には、永続モデルインデックス内の内部データポインタ、行、列、およびモデル値が使用されます。

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