QItemSelectionModel¶
The QItemSelectionModel
class keeps track of a view’s selected items. More…
Synopsis¶
Functions¶
def
columnIntersectsSelection
(column[, parent=QModelIndex()])def
currentIndex
()def
emitSelectionChanged
(newSelection, oldSelection)def
hasSelection
()def
isColumnSelected
(column[, parent=QModelIndex()])def
isRowSelected
(row[, parent=QModelIndex()])def
isSelected
(index)def
model
()def
rowIntersectsSelection
(row[, parent=QModelIndex()])def
selectedColumns
([row=0])def
selectedIndexes
()def
selectedRows
([column=0])def
selection
()def
setModel
(model)
Virtual functions¶
def
clear
()def
clearCurrentIndex
()def
reset
()def
select
(index, command)def
select
(selection, command)def
setCurrentIndex
(index, command)
Slots¶
def
clearSelection
()
Signals¶
def
currentChanged
(current, previous)def
currentColumnChanged
(current, previous)def
currentRowChanged
(current, previous)def
modelChanged
(model)def
selectionChanged
(selected, deselected)
Detailed Description¶
A QItemSelectionModel
keeps track of the selected items in a view, or in several views onto the same model. It also keeps track of the currently selected item in a view.
The QItemSelectionModel
class is one of the Model/View Classes and is part of Qt’s model/view framework .
The selected items are stored using ranges. Whenever you want to modify the selected items use select()
and provide either a QItemSelection
, or a QModelIndex
and a SelectionFlag
.
The QItemSelectionModel
takes a two layer approach to selection management, dealing with both selected items that have been committed and items that are part of the current selection. The current selected items are part of the current interactive selection (for example with rubber-band selection or keyboard-shift selections).
To update the currently selected items, use the bitwise OR of Current
and any of the other SelectionFlags
. If you omit the Current
command, a new current selection will be created, and the previous one added to the whole selection. All functions operate on both layers; for example, selecteditems()
will return items from both layers.
Note
Since 5.5, model
, hasSelection
, and currentIndex
are meta-object properties.
- class PySide6.QtCore.QItemSelectionModel([model=None])¶
PySide6.QtCore.QItemSelectionModel(model, parent)
- Parameters
parent –
PySide6.QtCore.QObject
Constructs a selection model that operates on the specified item model
.
Constructs a selection model that operates on the specified item model
with parent
.
- PySide6.QtCore.QItemSelectionModel.SelectionFlag¶
This enum describes the way the selection model will be updated.
Constant
Description
QItemSelectionModel.NoUpdate
No selection will be made.
QItemSelectionModel.Clear
The complete selection will be cleared.
QItemSelectionModel.Select
All specified indexes will be selected.
QItemSelectionModel.Deselect
All specified indexes will be deselected.
QItemSelectionModel.Toggle
All specified indexes will be selected or deselected depending on their current state.
QItemSelectionModel.Current
The current selection will be updated.
QItemSelectionModel.Rows
All indexes will be expanded to span rows.
QItemSelectionModel.Columns
All indexes will be expanded to span columns.
QItemSelectionModel.SelectCurrent
A combination of Select and Current, provided for convenience.
QItemSelectionModel.ToggleCurrent
A combination of Toggle and Current, provided for convenience.
QItemSelectionModel.ClearAndSelect
A combination of Clear and Select, provided for convenience.
- PySide6.QtCore.QItemSelectionModel.clear()¶
Clears the selection model. Emits selectionChanged()
and currentChanged()
.
- PySide6.QtCore.QItemSelectionModel.clearCurrentIndex()¶
Clears the current index. Emits currentChanged()
.
- PySide6.QtCore.QItemSelectionModel.clearSelection()¶
Clears the selection in the selection model. Emits selectionChanged()
.
- PySide6.QtCore.QItemSelectionModel.columnIntersectsSelection(column[, parent=QModelIndex()])¶
- Parameters
column – int
parent –
PySide6.QtCore.QModelIndex
- Return type
bool
Returns true
if there are any items selected in the column
with the given parent
.
Note
Since Qt 5.15, the default argument for parent
is an empty model index.
- PySide6.QtCore.QItemSelectionModel.currentChanged(current, previous)¶
- Parameters
current –
PySide6.QtCore.QModelIndex
previous –
PySide6.QtCore.QModelIndex
- PySide6.QtCore.QItemSelectionModel.currentColumnChanged(current, previous)¶
- Parameters
current –
PySide6.QtCore.QModelIndex
previous –
PySide6.QtCore.QModelIndex
- PySide6.QtCore.QItemSelectionModel.currentIndex()¶
- Return type
- PySide6.QtCore.QItemSelectionModel.currentRowChanged(current, previous)¶
- Parameters
current –
PySide6.QtCore.QModelIndex
previous –
PySide6.QtCore.QModelIndex
- PySide6.QtCore.QItemSelectionModel.emitSelectionChanged(newSelection, oldSelection)¶
- Parameters
newSelection –
PySide6.QtCore.QItemSelection
oldSelection –
PySide6.QtCore.QItemSelection
Compares the two selections newSelection
and oldSelection
and emits selectionChanged()
with the deselected and selected items.
- PySide6.QtCore.QItemSelectionModel.hasSelection()¶
- Return type
bool
- PySide6.QtCore.QItemSelectionModel.isColumnSelected(column[, parent=QModelIndex()])¶
- Parameters
column – int
parent –
PySide6.QtCore.QModelIndex
- Return type
bool
Returns true
if all items are selected in the column
with the given parent
.
Note that this function is usually faster than calling isSelected()
on all items in the same column and that unselectable items are ignored.
Note
Since Qt 5.15, the default argument for parent
is an empty model index.
- PySide6.QtCore.QItemSelectionModel.isRowSelected(row[, parent=QModelIndex()])¶
- Parameters
row – int
parent –
PySide6.QtCore.QModelIndex
- Return type
bool
Returns true
if all items are selected in the row
with the given parent
.
Note that this function is usually faster than calling isSelected()
on all items in the same row and that unselectable items are ignored.
Note
Since Qt 5.15, the default argument for parent
is an empty model index.
- PySide6.QtCore.QItemSelectionModel.isSelected(index)¶
- Parameters
index –
PySide6.QtCore.QModelIndex
- Return type
bool
Returns true
if the given model item index
is selected.
- PySide6.QtCore.QItemSelectionModel.model()¶
- Return type
- PySide6.QtCore.QItemSelectionModel.modelChanged(model)¶
- Parameters
- PySide6.QtCore.QItemSelectionModel.reset()¶
Clears the selection model. Does not emit any signals.
- PySide6.QtCore.QItemSelectionModel.rowIntersectsSelection(row[, parent=QModelIndex()])¶
- Parameters
row – int
parent –
PySide6.QtCore.QModelIndex
- Return type
bool
Returns true
if there are any items selected in the row
with the given parent
.
Note
Since Qt 5.15, the default argument for parent
is an empty model index.
- PySide6.QtCore.QItemSelectionModel.select(selection, command)¶
- Parameters
selection –
PySide6.QtCore.QItemSelection
command –
SelectionFlags
Selects the item selection
using the specified command
, and emits selectionChanged()
.
See also
SelectionFlag
- PySide6.QtCore.QItemSelectionModel.select(index, command)
- Parameters
index –
PySide6.QtCore.QModelIndex
command –
SelectionFlags
Selects the model item index
using the specified command
, and emits selectionChanged()
.
See also
SelectionFlags
- PySide6.QtCore.QItemSelectionModel.selectedColumns([row=0])¶
- Parameters
row – int
- Return type
QModelIndexList
Returns the indexes in the given row
for columns where all rows are selected.
See also
- PySide6.QtCore.QItemSelectionModel.selectedIndexes()¶
- Return type
QModelIndexList
- PySide6.QtCore.QItemSelectionModel.selectedRows([column=0])¶
- Parameters
column – int
- Return type
QModelIndexList
Returns the indexes in the given column
for the rows where all columns are selected.
See also
- PySide6.QtCore.QItemSelectionModel.selection()¶
- Return type
- PySide6.QtCore.QItemSelectionModel.selectionChanged(selected, deselected)¶
- Parameters
selected –
PySide6.QtCore.QItemSelection
deselected –
PySide6.QtCore.QItemSelection
- PySide6.QtCore.QItemSelectionModel.setCurrentIndex(index, command)¶
- Parameters
index –
PySide6.QtCore.QModelIndex
command –
SelectionFlags
Sets the model item index
to be the current item, and emits currentChanged()
. The current item is used for keyboard navigation and focus indication; it is independent of any selected items, although a selected item can also be the current item.
Depending on the specified command
, the index
can also become part of the current selection.
See also
- PySide6.QtCore.QItemSelectionModel.setModel(model)¶
- Parameters
© 2022 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.