- class QItemSelectionRange¶
The
QItemSelectionRange
class manages information about a range of selected items in a model. More…Synopsis¶
Methods¶
def
__init__()
def
bottom()
def
bottomRight()
def
contains()
def
height()
def
indexes()
def
intersected()
def
intersects()
def
isEmpty()
def
isValid()
def
left()
def
model()
def
__ne__()
def
__eq__()
def
parent()
def
right()
def
swap()
def
top()
def
topLeft()
def
width()
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 atop()
,left()
abottom()
,right()
and aparent()
.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. UseselectedIndexes()
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 theintersects()
function allows you to determine whether two ranges overlap.- __init__()¶
Constructs an empty selection range.
- __init__(index)
- Parameters:
index –
QModelIndex
Constructs a new selection range containing only the model item specified by the model index
index
.- __init__(topL, bottomR)
- Parameters:
topL –
QModelIndex
bottomR –
QModelIndex
Constructs a new selection range containing only the index specified by the
topLeft
and the indexbottomRight
.- bottom()¶
- Return type:
int
Returns the row index corresponding to the lowermost selected row in the selection range.
- bottomRight()¶
- Return type:
Returns the index for the item located at the bottom-right corner of the selection range.
- contains(index)¶
- Parameters:
index –
QModelIndex
- Return type:
bool
Returns
true
if the model item specified by theindex
lies within the range of selected items; otherwise returnsfalse
.- contains(row, column, parentIndex)
- Parameters:
row – int
column – int
parentIndex –
QModelIndex
- Return type:
bool
This is an overloaded function.
Returns
true
if the model item specified by (row
,column
) and withparentIndex
as the parent item lies within the range of selected items; otherwise returnsfalse
.- 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:
other –
QItemSelectionRange
- Return type:
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:
other –
QItemSelectionRange
- Return type:
bool
Returns
true
if this selection range intersects (overlaps with) theother
range given; otherwise returnsfalse
.- 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 returnsfalse
.- left()¶
- Return type:
int
Returns the column index corresponding to the leftmost selected column in the selection range.
- model()¶
- Return type:
Returns the model that the items in the selection range belong to.
- __ne__(rhs)¶
- Parameters:
rhs –
QItemSelectionRange
- Return type:
bool
Returns
true
iflhs
selection range differs from therhs
range given; otherwise returnsfalse
.- __eq__(rhs)¶
- Parameters:
rhs –
QItemSelectionRange
- Return type:
bool
Returns
true
iflhs
selection range is exactly the same as therhs
range given; otherwise returnsfalse
.- parent()¶
- Return type:
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:
other –
QItemSelectionRange
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:
Returns the index for the item located at the top-left corner of the selection range.
See also
- width()¶
- Return type:
int
Returns the number of selected columns in the selection range.