QPersistentModelIndex Class

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

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

このクラスは強く比較可能です。

このクラスはQModelIndex強く比較可能です。

パブリック関数

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)
QModelIndex 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 は、アプリケーションによって格納され、後でモデル内の情報にアクセスするために使用できるモデル・インデックスです。QPersistentModelIndex は、QModelIndex クラスとは異なり、モデルによってアクセスできる限り、項目への参照が有効 であり続けることが保証されるため、QPersistentModelIndex を格納することは安全です。

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

注釈 QStandardItemModel の QPersistentModelIndex をモデルの項目の 1 つに格納することはできません。

モデル/ビュー・プログラミングQModelIndex およびQAbstractItemModelも参照してください

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

QPersistentModelIndex::QPersistentModelIndex(const QModelIndex &index)

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

QPersistentModelIndex::QPersistentModelIndex(const QPersistentModelIndex &other)

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

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

Move - 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::ItemDataRoleQAbstractItemModel::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)

この永続的な modelindex をother と交換する。この操作は非常に高速で、失敗することはない。

QModelIndex QPersistentModelIndex::operator QModelIndex() const

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

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

Move-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 を返します。

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

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