Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QItemSelectionRange Class Reference

\inmodule QtCore More...

#include <qitemselectionmodel.h>

Collaboration diagram for QItemSelectionRange:

Public Member Functions

 QItemSelectionRange ()=default
 Constructs an empty selection range.
 QItemSelectionRange (const QModelIndex &topL, const QModelIndex &bottomR)
 Constructs a new selection range containing only the index specified by the topLeft and the index bottomRight.
 QItemSelectionRange (const QModelIndex &index)
 Constructs a new selection range containing only the model item specified by the model index index.
void swap (QItemSelectionRange &other) noexcept
int top () const
 Returns the row index corresponding to the uppermost selected row in the selection range.
int left () const
 Returns the column index corresponding to the leftmost selected column in the selection range.
int bottom () const
 Returns the row index corresponding to the lowermost selected row in the selection range.
int right () const
 Returns the column index corresponding to the rightmost selected column in the selection range.
int width () const
 Returns the number of selected columns in the selection range.
int height () const
 Returns the number of selected rows in the selection range.
const QPersistentModelIndextopLeft () const
 Returns the index for the item located at the top-left corner of the selection range.
const QPersistentModelIndexbottomRight () const
 Returns the index for the item located at the bottom-right corner of the selection range.
QModelIndex parent () const
 Returns the parent model item index of the items in the selection range.
const QAbstractItemModelmodel () const
 Returns the model that the items in the selection range belong to.
bool contains (const QModelIndex &index) const
 Returns true if the model item specified by the index lies within the range of selected items; otherwise returns false.
bool contains (int row, int column, const QModelIndex &parentIndex) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if the model item specified by (row, column) and with parentIndex as the parent item lies within the range of selected items; otherwise returns false.
bool intersects (const QItemSelectionRange &other) const
 Returns true if this selection range intersects (overlaps with) the other range given; otherwise returns false.
QItemSelectionRange intersected (const QItemSelectionRange &other) const
bool isValid () const
 Returns true if the selection range is valid; otherwise returns false.
bool isEmpty () const
 Returns true if the selection range contains either no items or only items which are either disabled or marked as not selectable.
QModelIndexList indexes () const
 Returns the list of model index items stored in the selection.

Friends

bool comparesEqual (const QItemSelectionRange &lhs, const QItemSelectionRange &rhs) noexcept

Detailed Description

\inmodule QtCore

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

\compares equality

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 QItemSelectionRange class is one of the \l{Model/View Classes} and is part of Qt's \l{Model/View Programming}{model/view framework}.

The model items contained in the selection range can be obtained using the indexes() 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, QItemSelectionModel

Definition at line 18 of file qitemselectionmodel.h.

Constructor & Destructor Documentation

◆ QItemSelectionRange() [1/3]

QItemSelectionRange::QItemSelectionRange ( )
default

Constructs an empty selection range.

◆ QItemSelectionRange() [2/3]

QItemSelectionRange::QItemSelectionRange ( const QModelIndex & topL,
const QModelIndex & bottomR )
inline

Constructs a new selection range containing only the index specified by the topLeft and the index bottomRight.

Definition at line 23 of file qitemselectionmodel.h.

◆ QItemSelectionRange() [3/3]

QItemSelectionRange::QItemSelectionRange ( const QModelIndex & index)
inlineexplicit

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

Definition at line 24 of file qitemselectionmodel.h.

Member Function Documentation

◆ bottom()

int QItemSelectionRange::bottom ( ) const
inline

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

Definition at line 34 of file qitemselectionmodel.h.

◆ bottomRight()

const QPersistentModelIndex & QItemSelectionRange::bottomRight ( ) const
inline

Returns the index for the item located at the bottom-right corner of the selection range.

See also
bottom(), right(), topLeft()

Definition at line 40 of file qitemselectionmodel.h.

◆ contains() [1/2]

bool QItemSelectionRange::contains ( const QModelIndex & index) const
inline

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

Definition at line 44 of file qitemselectionmodel.h.

◆ contains() [2/2]

bool QItemSelectionRange::contains ( int row,
int column,
const QModelIndex & parentIndex ) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if the model item specified by (row, column) and with parentIndex as the parent item lies within the range of selected items; otherwise returns false.

Definition at line 49 of file qitemselectionmodel.h.

◆ height()

int QItemSelectionRange::height ( ) const
inline

Returns the number of selected rows in the selection range.

Definition at line 37 of file qitemselectionmodel.h.

◆ indexes()

QModelIndexList QItemSelectionRange::indexes ( ) const

Returns the list of model index items stored in the selection.

Definition at line 363 of file qitemselectionmodel.cpp.

◆ intersected()

QItemSelectionRange QItemSelectionRange::intersected ( const QItemSelectionRange & other) const
Since
4.2

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

Definition at line 252 of file qitemselectionmodel.cpp.

◆ intersects()

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

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

Definition at line 226 of file qitemselectionmodel.cpp.

◆ isEmpty()

bool QItemSelectionRange::isEmpty ( ) const

Returns true if the selection range contains either no items or only items which are either disabled or marked as not selectable.

Since
4.7

Definition at line 344 of file qitemselectionmodel.cpp.

◆ isValid()

bool QItemSelectionRange::isValid ( ) const
inline

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

Definition at line 65 of file qitemselectionmodel.h.

◆ left()

int QItemSelectionRange::left ( ) const
inline

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

Definition at line 33 of file qitemselectionmodel.h.

◆ model()

const QAbstractItemModel * QItemSelectionRange::model ( ) const
inline

Returns the model that the items in the selection range belong to.

Definition at line 42 of file qitemselectionmodel.h.

◆ parent()

QModelIndex QItemSelectionRange::parent ( ) const
inline

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

Definition at line 41 of file qitemselectionmodel.h.

◆ right()

int QItemSelectionRange::right ( ) const
inline

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

Definition at line 35 of file qitemselectionmodel.h.

◆ swap()

void QItemSelectionRange::swap ( QItemSelectionRange & other)
inlinenoexcept
Since
5.6 \memberswap{selection range's contents}

Definition at line 26 of file qitemselectionmodel.h.

◆ top()

int QItemSelectionRange::top ( ) const
inline

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

Definition at line 32 of file qitemselectionmodel.h.

◆ topLeft()

const QPersistentModelIndex & QItemSelectionRange::topLeft ( ) const
inline

Returns the index for the item located at the top-left corner of the selection range.

See also
top(), left(), bottomRight()

Definition at line 39 of file qitemselectionmodel.h.

◆ width()

int QItemSelectionRange::width ( ) const
inline

Returns the number of selected columns in the selection range.

Definition at line 36 of file qitemselectionmodel.h.

◆ comparesEqual

bool comparesEqual ( const QItemSelectionRange & lhs,
const QItemSelectionRange & rhs )
friend

Definition at line 76 of file qitemselectionmodel.h.


The documentation for this class was generated from the following files: