class QItemSelectionRange#

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

Synopsis#

Methods#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

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 Model/View Classes and is part of Qt’s model/view framework.

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

__init__(index)#
Parameters:

indexQModelIndex

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

__init__(topL, bottomR)
Parameters:

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

__init__()

Constructs an empty selection range.

bottom()#
Return type:

int

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

bottomRight()#
Return type:

QPersistentModelIndex

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

contains(index)#
Parameters:

indexQModelIndex

Return type:

bool

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

contains(row, column, parentIndex)
Parameters:
  • row – int

  • column – int

  • parentIndexQModelIndex

Return type:

bool

This is an overloaded function.

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.

height()#
Return type:

int

Returns the number of selected rows in the selection range.

indexes()#
Return type:

.list of QModelIndex

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

intersected(other)#
Parameters:

otherQItemSelectionRange

Return type:

QItemSelectionRange

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

intersects(other)#
Parameters:

otherQItemSelectionRange

Return type:

bool

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

isEmpty()#
Return type:

bool

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

isValid()#
Return type:

bool

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

left()#
Return type:

int

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

model()#
Return type:

QAbstractItemModel

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

__ne__(other)#
Parameters:

otherQItemSelectionRange

Return type:

bool

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

__eq__(other)#
Parameters:

otherQItemSelectionRange

Return type:

bool

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

parent()#
Return type:

QModelIndex

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

right()#
Return type:

int

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

swap(other)#
Parameters:

otherQItemSelectionRange

Swaps this selection range’s contents with other. This function is very fast and never fails.

top()#
Return type:

int

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

topLeft()#
Return type:

QPersistentModelIndex

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

width()#
Return type:

int

Returns the number of selected columns in the selection range.