Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QItemSelectionRange Class Reference

The QItemSelectionRange class manages information about a range of selected items in a model. More...

    #include <QItemSelectionRange>

- List of all members, including inherited members

### Public Functions

- QItemSelectionRange ()
- QItemSelectionRange ( const QItemSelectionRange & other )
- QItemSelectionRange ( const QModelIndex & parent, int top, int left, int bottom, int right )
- QItemSelectionRange ( const QModelIndex & parent, const QModelIndex & index )
- int bottom () const
- bool contains ( const QModelIndex & index, const QAbstractItemModel * model ) const
- int height () const
- QItemSelectionRange intersect ( const QItemSelectionRange & other ) const
- bool intersects ( const QItemSelectionRange & other ) const
- bool isValid () const
- QModelIndexList items ( const QAbstractItemModel * model ) const
- int left () const
- QModelIndex parent () const
- int right () const
- int top () const
- int width () const
- bool operator!= ( const QItemSelectionRange & other ) const
- bool operator== ( const QItemSelectionRange & other ) const

## Detailed Description

The QItemSelectionRange class manages information about a range of selected items in a model.

A QItemSelectionRange contains information about a range of selected items in a model. A range of items is a contiguous array of model items, extending to cover a number of adjacent rows and columns with a common parent item; this can be visualized as a two-dimensional block of cells in a table. A selection range has a top(), left() a bottom(), right() and a parent().

The model items contained in the selection range can be obtained by using the items() function. Use QItemSelectionModel::selectedIndexes() to get a list of all selected items for a view.

You can determine whether a given model item lies within a particular range by using the contains() function. Ranges can also be compared using the overloaded operators for equality and inequality, and the intersects() function allows you to determine whether two ranges overlap.

See also Model/View Programming, QAbstractItemModel, QItemSelection, and QItemSelectionModel.

## Member Function Documentation

### QItemSelectionRange::QItemSelectionRange ()

Constructs an empty selection range.

### QItemSelectionRange::QItemSelectionRange ( const QItemSelectionRange & other )

Copy constructor. Constructs a new selection range with the same contents as the other range given.

### QItemSelectionRange::QItemSelectionRange ( const QModelIndex & parent, int top, int left, int bottom, int right )

Constructs a selection range containing the model items specified by the parent and the extents of the range: top, left, bottom, and right.

### QItemSelectionRange::QItemSelectionRange ( const QModelIndex & parent, const QModelIndex & index )

Constructs a new selection range containing only the model item specified by the parent and the model item index.

### int QItemSelectionRange::bottom () const

Returns the row index corresponding to the lowermost selected row in the selection range.

### bool QItemSelectionRange::contains ( const QModelIndex & index, const QAbstractItemModel * model ) const

Returns true if the model item specified by the index lies within the range of selected items for the given model; otherwise returns false.

### int QItemSelectionRange::height () const

Returns the number of selected rows in the selection range.

### QItemSelectionRange QItemSelectionRange::intersect ( const QItemSelectionRange & other ) const

Returns a new selection range containing only the items that are found in both the selection range and the other selection range.

### bool QItemSelectionRange::intersects ( const QItemSelectionRange & other ) const

Returns true if this selection range intersects (overlaps with) the other range given; otherwise returns false.

### bool QItemSelectionRange::isValid () const

Returns true if the selection range is valid; otherwise returns false.

### QModelIndexList QItemSelectionRange::items ( const QAbstractItemModel * model ) const

Returns the list of model index items stored for the given model.

### int QItemSelectionRange::left () const

Returns the column index corresponding to the leftmost selected column in the selection range.

### QModelIndex QItemSelectionRange::parent () const

Returns the parent model item index of the items in the selection range.

### int QItemSelectionRange::right () const

Returns the column index corresponding to the rightmost selected column in the selection range.

### int QItemSelectionRange::top () const

Returns the row index corresponding to the uppermost selected row in the selection range.

### int QItemSelectionRange::width () const

Returns the number of selected columns in the selection range.

### bool QItemSelectionRange::operator!= ( const QItemSelectionRange & other ) const

Returns true if the selection range differs from the other range given; otherwise returns false.

### bool QItemSelectionRange::operator== ( const QItemSelectionRange & other ) const

Returns true if the selection range is exactly the same as the other range given; otherwise returns false.