|  | Qt 6.x
    The Qt SDK | 
\inmodule QtCore More...
#include <qitemselectionmodel.h>
 Collaboration diagram for QItemSelectionRange:
 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 QPersistentModelIndex & | topLeft () const | 
| Returns the index for the item located at the top-left corner of the selection range. | |
| const QPersistentModelIndex & | bottomRight () 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 QAbstractItemModel * | model () const | 
| Returns the model that the items in the selection range belong to. | |
| bool | contains (const QModelIndex &index) const | 
| Returns trueif the model item specified by the index lies within the range of selected items; otherwise returnsfalse. | |
| 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 trueif the model item specified by (row, column) and with parentIndex as the parent item lies within the range of selected items; otherwise returnsfalse. | |
| bool | intersects (const QItemSelectionRange &other) const | 
| Returns trueif this selection range intersects (overlaps with) the other range given; otherwise returnsfalse. | |
| QItemSelectionRange | intersected (const QItemSelectionRange &other) const | 
| bool | operator== (const QItemSelectionRange &other) const | 
| Returns trueif the selection range is exactly the same as the other range given; otherwise returnsfalse. | |
| bool | operator!= (const QItemSelectionRange &other) const | 
| Returns trueif the selection range differs from the other range given; otherwise returnsfalse. | |
| bool | isValid () const | 
| Returns trueif the selection range is valid; otherwise returnsfalse. | |
| bool | isEmpty () const | 
| Returns trueif 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. | |
\inmodule QtCore
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 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.
Definition at line 17 of file qitemselectionmodel.h.
| 
 | default | 
Constructs an empty selection range.
Referenced by intersected().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | inline | 
Constructs a new selection range containing only the index specified by the topLeft and the index bottomRight.
Definition at line 22 of file qitemselectionmodel.h.
| 
 | inlineexplicit | 
Constructs a new selection range containing only the model item specified by the model index index.
Definition at line 23 of file qitemselectionmodel.h.
| 
 | inline | 
Returns the row index corresponding to the lowermost selected row in the selection range.
Definition at line 33 of file qitemselectionmodel.h.
Referenced by QItemSelectionModelPrivate::expandSelection(), intersected(), and isEmpty().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | inline | 
Returns the index for the item located at the bottom-right corner of the selection range.
Definition at line 39 of file qitemselectionmodel.h.
Referenced by intersected(), mergeIndexes(), and QTreeViewPrivate::select().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | inline | 
Returns true if the model item specified by the index lies within the range of selected items; otherwise returns false. 
Definition at line 43 of file qitemselectionmodel.h.
References parent.
| 
 | 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 50 of file qitemselectionmodel.h.
References parent, and QModelIndex::row().
 Here is the call graph for this function:
 Here is the call graph for this function:| 
 | inline | 
Returns the number of selected rows in the selection range.
Definition at line 36 of file qitemselectionmodel.h.
| QModelIndexList QItemSelectionRange::indexes | ( | ) | const | 
Returns the list of model index items stored in the selection.
Definition at line 315 of file qitemselectionmodel.cpp.
References indexesFromRange().
 Here is the call graph for this function:
 Here is the call graph for this function:| QItemSelectionRange QItemSelectionRange::intersected | ( | 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.
Definition at line 204 of file qitemselectionmodel.cpp.
References QItemSelectionRange(), bottom(), bottomRight(), QAbstractItemModel::index(), left(), model(), other(), parent(), qMax(), qMin(), right(), top(), and topLeft().
Referenced by QItemSelectionModel::emitSelectionChanged(), and QQmlItemSelectionRangeValueType::intersected().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 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 183 of file qitemselectionmodel.cpp.
References model, other(), and parent.
Referenced by QItemSelectionModel::emitSelectionChanged(), and QItemSelection::merge().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 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. 
Definition at line 296 of file qitemselectionmodel.cpp.
References bottom(), QAbstractItemModel::index(), isSelectableAndEnabled(), isValid(), left(), model(), parent(), right(), and top().
 Here is the call graph for this function:
 Here is the call graph for this function:| 
 | inline | 
Returns true if the selection range is valid; otherwise returns false. 
Definition at line 66 of file qitemselectionmodel.h.
Referenced by isEmpty(), and QTreeViewPrivate::select().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | inline | 
Returns the column index corresponding to the leftmost selected column in the selection range.
Definition at line 32 of file qitemselectionmodel.h.
Referenced by QItemSelectionModelPrivate::expandSelection(), intersected(), isEmpty(), and QTreeViewPrivate::select().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | inline | 
Returns the model that the items in the selection range belong to.
Definition at line 41 of file qitemselectionmodel.h.
Referenced by intersected(), and isEmpty().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | inline | 
Returns true if the selection range differs from the other range given; otherwise returns false. 
Definition at line 63 of file qitemselectionmodel.h.
References operator==(), and other().
 Here is the call graph for this function:
 Here is the call graph for this function:| 
 | inline | 
Returns true if the selection range is exactly the same as the other range given; otherwise returns false. 
Definition at line 61 of file qitemselectionmodel.h.
References other().
 Here is the call graph for this function:
 Here is the call graph for this function:| 
 | inline | 
Returns the parent model item index of the items in the selection range.
Definition at line 40 of file qitemselectionmodel.h.
References QModelIndex::parent().
Referenced by QItemSelectionModelPrivate::expandSelection(), intersected(), isEmpty(), and QTreeViewPrivate::select().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | inline | 
Returns the column index corresponding to the rightmost selected column in the selection range.
Definition at line 34 of file qitemselectionmodel.h.
Referenced by QItemSelectionModelPrivate::expandSelection(), intersected(), and isEmpty().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | inlinenoexcept | 
Swaps this selection range's contents with other. This function is very fast and never fails.
Definition at line 25 of file qitemselectionmodel.h.
References other().
 Here is the call graph for this function:
 Here is the call graph for this function:| 
 | inline | 
Returns the row index corresponding to the uppermost selected row in the selection range.
Definition at line 31 of file qitemselectionmodel.h.
Referenced by QItemSelectionModelPrivate::expandSelection(), intersected(), isEmpty(), and QTreeViewPrivate::select().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | inline | 
Returns the index for the item located at the top-left corner of the selection range.
Definition at line 38 of file qitemselectionmodel.h.
Referenced by intersected(), and mergeIndexes().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | inline | 
Returns the number of selected columns in the selection range.
Definition at line 35 of file qitemselectionmodel.h.