|  | Home · Overviews · Examples |

# QItemSelectionModel Class Reference
[com.trolltech.qt.gui module]

The `QItemSelectionModel` class keeps track of a view's selected items. More...

Inherits `QObject`.

## Detailed Description

The `QItemSelectionModel` class keeps track of a view's selected items.

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 QItemSelectionModel::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 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 committed selection. All functions operate on both layers; for example, selectedItems() will return items from both layers.

See also Model/View Programming, `QAbstractItemModel`, and Chart Example.