QItemSelection Class

QItemSelectionクラスは、モデル内で選択されたアイテムに関する情報を管理します。詳細...

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

パブリック関数

QItemSelection()
QItemSelection(const QModelIndex &topLeft, const QModelIndex &bottomRight)
bool contains(const QModelIndex &index) const
QModelIndexList indexes() const
void merge(const QItemSelection &other, QItemSelectionModel::SelectionFlags command)
void select(const QModelIndex &topLeft, const QModelIndex &bottomRight)

静的パブリックメンバ

void split(const QItemSelectionRange &range, const QItemSelectionRange &other, QItemSelection *result)

詳細説明

QItemSelection は、ユーザーによって選択されたモデル内の項目を記述します。QItemSelection は、基本的に選択範囲のリストです。QItemSelectionRange を参照してください。QItemSelection は、基本的に、選択範囲のリストです。QItemSelection は、選択範囲の作成と操作、およびモデルから項目の範囲を選択するための関数を提供します。

QItemSelectionクラスはモデル/ビュー・クラスの1つで、Qtのモデル/ビュー・フレームワークの一部です。

アイテム選択は、既存のモデルからアイテムの範囲を含むように構築し、初期化することができます。以下の例では、与えられたmodel から、topLeft で始まり、bottomRight で終わるアイテムの範囲を含む選択を構築します。

QItemSelection *selection = new QItemSelection(topLeft, bottomRight);

空の項目選択を構築し、後で必要に応じて入力することもできます。そのため、アイテム・セレクションを構築するときにモデルが利用できない場合は、上記のコードを次のように書き換えることができます:

QItemSelection *selection = new QItemSelection();
...
selection->select(topLeft, bottomRight);

QItemSelectionは、選択項目の各項目についてモデルの項目インデックスを記録するのではなく、選択範囲を扱うことによって、メモリを節約し、不必要な作業を避けることができます。一般的に、このクラスのインスタンスは、重複しない選択範囲のリストを含みます。

重複する範囲を作らずに、ある項目の選択範囲を別の項目にマージするにはmerge() を使用します。ある選択範囲を、別の選択範囲に基づいてより小さな範囲に分割するにはsplit() を使用します。

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

メンバ関数ドキュメント

[noexcept default] QItemSelection::QItemSelection()

空の選択範囲を作成します。

QItemSelection::QItemSelection(const QModelIndex &topLeft, const QModelIndex &bottomRight)

topLeft インデックスで指定される左上のモデル項目から、bottomRight で指定される右下の項目まで拡張する項目選択を構築する。

bool QItemSelection::contains(const QModelIndex &index) const

選択範囲に与えられたindex が含まれていればtrue を返し、そうでなければfalse を返す。

QModelIndexList QItemSelection::indexes() const

選択された項目に対応するモデルインデックスのリストを返します。

void QItemSelection::merge(const QItemSelection &other, QItemSelectionModel::SelectionFlags command)

指定されたcommand を使って、other の選択範囲をこのQItemSelection にマージする。このメソッドは、範囲が重複しないことを保証する。

QItemSelectionModel::Select,QItemSelectionModel::Deselect,QItemSelectionModel::Toggle のみがサポートされていることに注意してください。

split()も参照

void QItemSelection::select(const QModelIndex &topLeft, const QModelIndex &bottomRight)

topLeft で指定された左上のモデル項目からbottomRight で指定された右下のモデル項目までの範囲の項目をリストに追加します。

注意: topLeftbottomRight は同じ親でなければなりません。

[static] void QItemSelection::split(const QItemSelectionRange &range, const QItemSelectionRange &other, QItemSelection *result)

選択範囲other を使って選択範囲range を分割する。range からother のすべての項目を削除し、その結果をresult に入れます。これは、集合の減算操作のセマンティクスと比較することができます。

merge()も参照してください

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