QItemSelectionModel

Inheritance diagram of QItemSelectionModel

Synopsis

Functions

Virtual functions

Slots

Signals

Detailed Description

The PySide.QtGui.QItemSelectionModel class keeps track of a view’s selected items.

A PySide.QtGui.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 PySide.QtGui.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 PySide.QtGui.QItemSelectionModel.select() and provide either a PySide.QtGui.QItemSelection , or a PySide.QtCore.QModelIndex and a QItemSelectionModel.SelectionFlag .

The PySide.QtGui.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 QItemSelectionModel.Current and any of the other SelectionFlags . If you omit the QItemSelectionModel.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.

See also

Model/View Programming PySide.QtCore.QAbstractItemModel Chart Example

class PySide.QtGui.QItemSelectionModel(model)
class PySide.QtGui.QItemSelectionModel(model, parent)
Parameters:

Constructs a selection model that operates on the specified item model .

Constructs a selection model that operates on the specified item model with parent .

PySide.QtGui.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.
PySide.QtGui.QItemSelectionModel.clear()

Clears the selection model. Emits PySide.QtGui.QItemSelectionModel.selectionChanged() and PySide.QtGui.QItemSelectionModel.currentChanged() .

PySide.QtGui.QItemSelectionModel.clearSelection()

Clears the selection in the selection model. Emits PySide.QtGui.QItemSelectionModel.selectionChanged() .

PySide.QtGui.QItemSelectionModel.columnIntersectsSelection(column, parent)
Parameters:
Return type:

PySide.QtCore.bool

Returns true if there are any items selected in the column with the given parent .

PySide.QtGui.QItemSelectionModel.currentChanged(current, previous)
Parameters:
PySide.QtGui.QItemSelectionModel.currentColumnChanged(current, previous)
Parameters:
PySide.QtGui.QItemSelectionModel.currentIndex()
Return type:PySide.QtCore.QModelIndex

Returns the model item index for the current item, or an invalid index if there is no current item.

PySide.QtGui.QItemSelectionModel.currentRowChanged(current, previous)
Parameters:
PySide.QtGui.QItemSelectionModel.emitSelectionChanged(newSelection, oldSelection)
Parameters:

Compares the two selections newSelection and oldSelection and emits PySide.QtGui.QItemSelectionModel.selectionChanged() with the deselected and selected items.

PySide.QtGui.QItemSelectionModel.hasSelection()
Return type:PySide.QtCore.bool

Returns true if the selection model contains any selection ranges; otherwise returns false.

PySide.QtGui.QItemSelectionModel.isColumnSelected(column, parent)
Parameters:
Return type:

PySide.QtCore.bool

Returns true if all items are selected in the column with the given parent .

Note that this function is usually faster than calling PySide.QtGui.QItemSelectionModel.isSelected() on all items in the same column and that unselectable items are ignored.

PySide.QtGui.QItemSelectionModel.isRowSelected(row, parent)
Parameters:
Return type:

PySide.QtCore.bool

Returns true if all items are selected in the row with the given parent .

Note that this function is usually faster than calling PySide.QtGui.QItemSelectionModel.isSelected() on all items in the same row and that unselectable items are ignored.

PySide.QtGui.QItemSelectionModel.isSelected(index)
Parameters:indexPySide.QtCore.QModelIndex
Return type:PySide.QtCore.bool

Returns true if the given model item index is selected.

PySide.QtGui.QItemSelectionModel.model()
Return type:PySide.QtCore.QAbstractItemModel

Returns the item model operated on by the selection model.

PySide.QtGui.QItemSelectionModel.reset()

Clears the selection model. Does not emit any signals.

PySide.QtGui.QItemSelectionModel.rowIntersectsSelection(row, parent)
Parameters:
Return type:

PySide.QtCore.bool

Returns true if there are any items selected in the row with the given parent .

PySide.QtGui.QItemSelectionModel.select(index, command)
Parameters:
PySide.QtGui.QItemSelectionModel.select(selection, command)
Parameters:
PySide.QtGui.QItemSelectionModel.selectedColumns([row=0])
Parameters:rowPySide.QtCore.int
Return type:

Returns the indexes in the given row for columns where all rows are selected.

PySide.QtGui.QItemSelectionModel.selectedIndexes()
Return type:

Returns a list of all selected model item indexes. The list contains no duplicates, and is not sorted.

PySide.QtGui.QItemSelectionModel.selectedRows([column=0])
Parameters:columnPySide.QtCore.int
Return type:

Returns the indexes in the given column for the rows where all columns are selected.

PySide.QtGui.QItemSelectionModel.selection()
Return type:PySide.QtGui.QItemSelection

Returns the selection ranges stored in the selection model.

PySide.QtGui.QItemSelectionModel.selectionChanged(selected, deselected)
Parameters:
PySide.QtGui.QItemSelectionModel.setCurrentIndex(index, command)
Parameters: