QItemSelectionModel Class
QItemSelectionModel クラスは、ビューの選択された項目を追跡します。もっと詳しく...
ヘッダ | #include <QItemSelectionModel> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
継承: | QObject |
パブリックな型
enum | SelectionFlag { NoUpdate, Clear, Select, Deselect, Toggle, …, ClearAndSelect } |
flags | SelectionFlags |
プロパティ
- selectedIndexes : const QModelIndexList
パブリック機能
QItemSelectionModel(QAbstractItemModel *model = nullptr) | |
QItemSelectionModel(QAbstractItemModel *model, QObject *parent) | |
virtual | ~QItemSelectionModel() |
bool | columnIntersectsSelection(int column, const QModelIndex &parent = QModelIndex()) const |
QModelIndex | currentIndex() const |
bool | hasSelection() const |
bool | isColumnSelected(int column, const QModelIndex &parent = QModelIndex()) const |
bool | isRowSelected(int row, const QModelIndex &parent = QModelIndex()) const |
bool | isSelected(const QModelIndex &index) const |
QAbstractItemModel * | model() |
const QAbstractItemModel * | model() const |
bool | rowIntersectsSelection(int row, const QModelIndex &parent = QModelIndex()) const |
QModelIndexList | selectedColumns(int row = 0) const |
QModelIndexList | selectedIndexes() const |
QModelIndexList | selectedRows(int column = 0) const |
const QItemSelection | selection() const |
void | setModel(QAbstractItemModel *model) |
パブリックスロット
virtual void | clear() |
virtual void | clearCurrentIndex() |
void | clearSelection() |
virtual void | reset() |
virtual void | select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) |
virtual void | select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) |
virtual void | setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) |
シグナル
void | currentChanged(const QModelIndex ¤t, const QModelIndex &previous) |
void | currentColumnChanged(const QModelIndex ¤t, const QModelIndex &previous) |
void | currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous) |
void | modelChanged(QAbstractItemModel *model) |
void | selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) |
保護された関数
void | emitSelectionChanged(const QItemSelection &newSelection, const QItemSelection &oldSelection) |
詳しい説明
QItemSelectionModel は、1つのビュー、または同じモデル上の複数のビューで選択された項目を追跡します。また、ビューで現在選択されている項目の追跡も行います。
QItemSelectionModel クラスは、モデル/ビュー・クラスの一つであり、Qt のモデル/ビュー・フレームワークの一部です。
選択された項目は範囲を使って保存されます。選択された項目を変更したい場合は、select ()を使用し、QItemSelection 、またはQModelIndex 、QItemSelectionModel::SelectionFlag 。
QItemSelectionModel は、コミットされた選択項目と、現在の選択項目の一部である項目の両方を扱う、選択項目管理に2つのレイヤー・アプローチを取ります。現在の選択項目は、現在のインタラクティブな選択項目の一部です(ラバーバンド選択やキーボードシフト選択など)。
現在選択されている項目を更新するには、QItemSelectionModel::Current と他のSelectionFlags のビットの OR を使います。QItemSelectionModel::Current コマンドを省略すると、 新しい現在の選択範囲が作成され、 以前の選択範囲が選択範囲全体に追加されます。例えば、selecteditems() は、両方のレイヤーから項目を返します。
注: 5.5以降、model 、hasSelection 、currentIndex はメタ・オブジェクト・プロパティです。
モデル/ビュー・プログラミングおよびQAbstractItemModelも参照してください 。
メンバ型のドキュメント
enum QItemSelectionModel::SelectionFlag
flags QItemSelectionModel::SelectionFlags
この列挙型は、選択モデルが更新される方法を記述します。
定数 | 値 | 説明 |
---|---|---|
QItemSelectionModel::NoUpdate | 0x0000 | 選択は行われません。 |
QItemSelectionModel::Clear | 0x0001 | 完全な選択はクリアされます。 |
QItemSelectionModel::Select | 0x0002 | 指定されたすべてのインデックスが選択されます。 |
QItemSelectionModel::Deselect | 0x0004 | 指定されたすべてのインデックスが選択解除されます。 |
QItemSelectionModel::Toggle | 0x0008 | 指定されたすべてのインデックスが現在の状態に応じて選択または選択解除されます。 |
QItemSelectionModel::Current | 0x0010 | 現在の選択範囲が更新される。 |
QItemSelectionModel::Rows | 0x0020 | すべてのインデックスが行にまたがって展開されます。 |
QItemSelectionModel::Columns | 0x0040 | すべてのインデックスが列をまたぐように展開される。 |
QItemSelectionModel::SelectCurrent | Select | Current | SelectとCurrentの組み合わせ。 |
QItemSelectionModel::ToggleCurrent | Toggle | Current | ToggleとCurrentの組み合わせ。 |
QItemSelectionModel::ClearAndSelect | Clear | Select | Clear と Select の組み合わせ。 |
SelectionFlags型はQFlags<SelectionFlag>のtypedefである。SelectionFlag値のORの組み合わせを格納する。
プロパティ・ドキュメント
[read-only]
selectedIndexes : const QModelIndexList
アクセス機能
QModelIndexList | selectedIndexes() const |
通知シグナル
void | selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) |
メンバ関数ドキュメント
[explicit]
QItemSelectionModel::QItemSelectionModel(QAbstractItemModel *model = nullptr)
指定された項目model を操作する選択モデルを構築する。
[explicit]
QItemSelectionModel::QItemSelectionModel(QAbstractItemModel *model, QObject *parent)
parent で指定された項目model を操作する選択モデルを構築する。
[virtual noexcept]
QItemSelectionModel::~QItemSelectionModel()
選択モデルを破壊する。
[virtual slot]
void QItemSelectionModel::clear()
選択モデルをクリアする。selectionChanged() とcurrentChanged() を発する。
[virtual slot]
void QItemSelectionModel::clearCurrentIndex()
現在のインデックスをクリアします。currentChanged() を返す。
[slot]
void QItemSelectionModel::clearSelection()
セレクションモデルのセレクションをクリアします。selectionChanged() を出す。
[invokable]
bool QItemSelectionModel::columnIntersectsSelection(int column, const QModelIndex &parent = QModelIndex()) const
与えられたparent を持つcolumn で選択されているアイテムがあればtrue
を返します。
注 : Qt 5.15 以降、parent のデフォルトの引数は空のモデル・インデックスです。
注意 : この関数はメタオブジェクトシステムやQMLから呼び出すことができます。Q_INVOKABLE を参照してください。
[signal]
void QItemSelectionModel::currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
このシグナルはカレントアイテムが変更されるたびに発行される。previous モデルのアイテムインデックスは、セレクションの現在のアイテムとしてcurrent インデックスに置き換えられます。
アイテムモデルがリセットされると、このシグナルは発せられないことに注意してください。
currentIndex(),setCurrentIndex(),selectionChanged()も参照 。
[signal]
void QItemSelectionModel::currentColumnChanged(const QModelIndex ¤t, const QModelIndex &previous)
このシグナルは、current アイテムが変更され、そのカラムがprevious 現在のアイテムのカラムと異なる場合に発行される。
アイテムモデルがリセットされると、このシグナルは発行されないことに注意してください。
currentChanged(),currentRowChanged(),currentIndex(),setCurrentIndex()も参照 。
QModelIndex QItemSelectionModel::currentIndex() const
現在のアイテムのモデル・アイテム・インデックス、または現在のアイテムがない場合は無効なインデックスを返します。
setCurrentIndex()も参照してください 。
[signal]
void QItemSelectionModel::currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous)
このシグナルは、current アイテムが変更され、その行がprevious 現在のアイテムの行と異なる場合に発行される。
アイテムモデルがリセットされると、このシグナルは発行されないことに注意してください。
currentChanged(),currentColumnChanged(),currentIndex(),setCurrentIndex()も参照のこと 。
[protected]
void QItemSelectionModel::emitSelectionChanged(const QItemSelection &newSelection, const QItemSelection &oldSelection)
2つの選択項目newSelection とoldSelection を比較し、非選択項目と選択項目でselectionChanged() を出す。
bool QItemSelectionModel::hasSelection() const
選択モデルに選択項目が含まれていればtrue
を返し、そうでなければfalse
を返す。
[invokable]
bool QItemSelectionModel::isColumnSelected(int column, const QModelIndex &parent = QModelIndex()) const
与えられたparent で、すべての項目がcolumn で選択されている場合、true
を返す。
この関数は通常、同じ列のすべての項目に対してisSelected() を呼び出すよりも高速であり、選択不可能な項目は無視されることに注意してください。
注意 : Qt 5.15 以降、parent のデフォルトの引数は空のモデル・インデックスです。
注意 : この関数は、メタオブジェクトシステムや QML から呼び出すことができます。Q_INVOKABLE を参照してください。
[invokable]
bool QItemSelectionModel::isRowSelected(int row, const QModelIndex &parent = QModelIndex()) const
与えられたparent を持つrow で、すべての項目が選択されている場合、true
を返す。
この関数は通常、同じ行のすべての項目に対してisSelected() を呼び出すよりも高速であり、選択不可能な項目は無視されることに注意してください。
注意 : Qt 5.15 以降、parent のデフォルト引数は空のモデル・インデックスです。
注意 : この関数は、メタオブジェクトシステムや QML から呼び出すことができます。Q_INVOKABLE を参照してください。
[invokable]
bool QItemSelectionModel::isSelected(const QModelIndex &index) const
与えられたモデルアイテムindex が選択された場合、true
を返します。
注意: この関数はメタオブジェクトシステムやQMLから呼び出すことができます。Q_INVOKABLE を参照してください。
QAbstractItemModel *QItemSelectionModel::model()
選択モデルによって操作されたアイテムモデルを返します。
setModel()も参照してください 。
const QAbstractItemModel *QItemSelectionModel::model() const
選択モデルによって操作されたアイテムモデルを返します。
[signal]
void QItemSelectionModel::modelChanged(QAbstractItemModel *model)
このシグナルは、setModel() でmodel が正常に設定されたときに発せられる。
[virtual slot]
void QItemSelectionModel::reset()
選択モデルをクリアする。シグナルは出さない。
[invokable]
bool QItemSelectionModel::rowIntersectsSelection(int row, const QModelIndex &parent = QModelIndex()) const
与えられたparent を持つrow で選択されているアイテムがあればtrue
を返します。
注 : Qt 5.15 以降、parent のデフォルトの引数は空のモデル・インデックスです。
注意 : この関数はメタオブジェクトシステムやQMLから呼び出すことができます。Q_INVOKABLE を参照してください。
[virtual slot]
void QItemSelectionModel::select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command)
指定されたcommand を使って項目selection を選択し、selectionChanged() を発する。
QItemSelectionModel::SelectionFlagも参照のこと 。
[virtual slot]
void QItemSelectionModel::select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
指定されたcommand を用いてモデル項目index を選択し、selectionChanged() を発する。
QItemSelectionModel::SelectionFlagsも参照 。
[invokable]
QModelIndexList QItemSelectionModel::selectedColumns(int row = 0) const
全ての行が選択されている列について、与えられたrow のインデックスを返す。
注意: この関数はメタオブジェクトシステムやQMLから呼び出すことができます。Q_INVOKABLE を参照してください。
selectedIndexes() およびselectedRows()も参照の こと。
QModelIndexList QItemSelectionModel::selectedIndexes() const
選択されたすべてのモデル項目のインデックスのリストを返します。リストは重複を含まず、ソートされません。
注: selectedIndexes プロパティのゲッター関数です。
[invokable]
QModelIndexList QItemSelectionModel::selectedRows(int column = 0) const
全ての列が選択されている行について、与えられたcolumn のインデックスを返す。
注意: この関数はメタオブジェクトシステムやQMLから呼び出すことができます。Q_INVOKABLE を参照してください。
selectedIndexes() およびselectedColumns()も参照 。
const QItemSelection QItemSelectionModel::selection() const
選択モデルに格納されている選択範囲を返します。
[signal]
void QItemSelectionModel::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
このシグナルは、セレクションが変更されるたびに発せられる。選択範囲の変更は、deselected 項目の項目選択と、selected 項目の項目選択として表現される。
現在のインデックスはセレクションとは無関係に変化することに注意してください。また、このシグナルはアイテムモデルがリセットされたときには発せられないことにも注意してください。
選択されたままインデックスが変化するアイテムは、selected とdeselected には含まれません。したがって、選択されたアイテムのインデックスのみが変更された場合、selected とdeselected の両方が空の状態でこのシグナルが発行される可能性があります。
注: selectedIndexes プロパティのノーティファイア・シグナル。
select() およびcurrentChanged()も参照してください 。
[virtual slot]
void QItemSelectionModel::setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
モデルアイテムindex をカレントアイテムに設定し、currentChanged() を出力する。カレントアイテムは、キーボードナビゲーションとフォーカスの表示に使われます。カレントアイテムは、選択されたアイテムとは無関係ですが、選択されたアイテムがカレントアイテムになることもあります。
指定されたcommand に応じて、index も現在の選択項目の一部となる。
currentIndex() およびselect()も参照のこと 。
void QItemSelectionModel::setModel(QAbstractItemModel *model)
モデルをmodel に設定する。modelChanged() シグナルが発せられる。
model() およびmodelChanged()も参照 。
© 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.