- class QItemSelection#
The
QItemSelection
class manages information about selected items in a model. More…Synopsis#
Methods#
def
__init__()
def
append()
def
at()
def
back()
def
capacity()
def
clear()
def
constData()
def
constFirst()
def
constLast()
def
contains()
def
count()
def
data()
def
empty()
def
first()
def
front()
def
indexes()
def
insert()
def
isEmpty()
def
isSharedWith()
def
last()
def
length()
def
merge()
def
mid()
def
move()
def
__ne__()
def
__add__()
def
__iadd__()
def
__lshift__()
def
__eq__()
def
operator[]()
def
pop_back()
def
pop_front()
def
prepend()
def
push_back()
def
push_front()
def
remove()
def
removeAll()
def
removeAt()
def
removeFirst()
def
removeLast()
def
removeOne()
def
reserve()
def
resize()
def
select()
def
shrink_to_fit()
def
size()
def
sliced()
def
squeeze()
def
swap()
def
swapItemsAt()
def
takeAt()
def
toList()
def
toVector()
def
value()
Static functions#
def
fromList()
def
fromVector()
def
split()
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#
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
A
QItemSelection
describes the items in a model that have been selected by the user. AQItemSelection
is basically a list of selection ranges, seeQItemSelectionRange
. It provides functions for creating and manipulating selections, and selecting a range of items from a model.The
QItemSelection
class is one of the Model/View Classes and is part of Qt’s model/view framework.An item selection can be constructed and initialized to contain a range of items from an existing model. The following example constructs a selection that contains a range of items from the given
model
, beginning at thetopLeft
, and ending at thebottomRight
.selection = QItemSelection(topLeft, bottomRight)
An empty item selection can be constructed, and later populated as required. So, if the model is going to be unavailable when we construct the item selection, we can rewrite the above code in the following way:
selection = QItemSelection() ... selection.select(topLeft, bottomRight)
QItemSelection
saves memory, and avoids unnecessary work, by working with selection ranges rather than recording the model item index for each item in the selection. Generally, an instance of this class will contain a list of non-overlapping selection ranges.Use
merge()
to merge one item selection into another without making overlapping ranges. Usesplit()
to split one selection range into smaller ranges based on a another selection range.See also
- __init__(topLeft, bottomRight)#
- Parameters:
topLeft –
QModelIndex
bottomRight –
QModelIndex
Constructs an item selection that extends from the top-left model item, specified by the
topLeft
index, to the bottom-right item, specified bybottomRight
.- __init__()
Constructs an empty selection.
- append(l)#
- Parameters:
l – .list of QItemSelectionRange
- append(arg__1)
- Parameters:
arg__1 –
QItemSelectionRange
- at(i)#
- Parameters:
i – int
- Return type:
- back()#
- Return type:
- capacity()#
- Return type:
int
- clear()#
- constData()#
- Return type:
- constFirst()#
- Return type:
- constLast()#
- Return type:
- contains(index)#
- Parameters:
index –
QModelIndex
- Return type:
bool
Returns
true
if the selection contains the givenindex
; otherwise returnsfalse
.- count()#
- Return type:
int
- data()#
- Return type:
- empty()#
- Return type:
bool
- first()#
- Return type:
- first(n)
- Parameters:
n – int
- Return type:
.list of QItemSelectionRange
- static fromList(list)#
- Parameters:
list – .list of QItemSelectionRange
- Return type:
.list of QItemSelectionRange
- static fromVector(vector)#
- Parameters:
vector – .list of QItemSelectionRange
- Return type:
.list of QItemSelectionRange
- front()#
- Return type:
- indexes()#
- Return type:
.list of QModelIndex
Returns a list of model indexes that correspond to the selected items.
- insert(arg__1, arg__2)#
- Parameters:
arg__1 – int
arg__2 –
QItemSelectionRange
- isEmpty()#
- Return type:
bool
- Parameters:
other – .list of QItemSelectionRange
- Return type:
bool
- last()#
- Return type:
- last(n)
- Parameters:
n – int
- Return type:
.list of QItemSelectionRange
- length()#
- Return type:
int
- merge(other, command)#
- Parameters:
other –
QItemSelection
command – Combination of
SelectionFlag
Merges the
other
selection with thisQItemSelection
using thecommand
given. This method guarantees that no ranges are overlapping.Note that only
Select
,Deselect
, andToggle
are supported.See also
- mid(pos[, len=-1])#
- Parameters:
pos – int
len – int
- Return type:
.list of QItemSelectionRange
- move(from, to)#
- Parameters:
from – int
to – int
- __ne__(arg__1)#
- Parameters:
arg__1 –
QItemSelection
- Return type:
bool
- __add__(arg__1)#
- Parameters:
arg__1 –
QItemSelection
- Return type:
- __iadd__(l)#
- Parameters:
l – .list of QItemSelectionRange
- Return type:
.list of QItemSelectionRange
- __lshift__(l)#
- Parameters:
l – .list of QItemSelectionRange
- Return type:
.list of QItemSelectionRange
- __eq__(arg__1)#
- Parameters:
arg__1 –
QItemSelection
- Return type:
bool
- operator(i)#
- Parameters:
i – int
- Return type:
- pop_back()#
- pop_front()#
- prepend(arg__1)#
- Parameters:
arg__1 –
QItemSelectionRange
- push_back(arg__1)#
- Parameters:
arg__1 –
QItemSelectionRange
- push_front(arg__1)#
- Parameters:
arg__1 –
QItemSelectionRange
- remove(i[, n=1])#
- Parameters:
i – int
n – int
- removeAll(arg__1)#
- Parameters:
arg__1 –
QItemSelectionRange
- removeAt(i)#
- Parameters:
i – int
- removeFirst()#
- removeLast()#
- removeOne(arg__1)#
- Parameters:
arg__1 –
QItemSelectionRange
- reserve(size)#
- Parameters:
size – int
- resize(size)#
- Parameters:
size – int
- select(topLeft, bottomRight)#
- Parameters:
topLeft –
QModelIndex
bottomRight –
QModelIndex
Adds the items in the range that extends from the top-left model item, specified by the
topLeft
index, to the bottom-right item, specified bybottomRight
to the list.Note
topLeft
andbottomRight
must have the same parent.- shrink_to_fit()#
- size()#
- Return type:
int
- sliced(pos)#
- Parameters:
pos – int
- Return type:
.list of QItemSelectionRange
- sliced(pos, n)
- Parameters:
pos – int
n – int
- Return type:
.list of QItemSelectionRange
- static split(range, other, result)#
- Parameters:
range –
QItemSelectionRange
other –
QItemSelectionRange
result –
QItemSelection
Splits the selection
range
using the selectionother
range. Removes all items inother
fromrange
and puts the result inresult
. This can be compared with the semantics of the subtract operation of a set.See also
- squeeze()#
- swap(other)#
- Parameters:
other – .list of QItemSelectionRange
- swapItemsAt(i, j)#
- Parameters:
i – int
j – int
- takeAt(i)#
- Parameters:
i – int
- Return type:
- toList()#
- Return type:
.list of QItemSelectionRange
- toVector()#
- Return type:
.list of QItemSelectionRange
- value(i)#
- Parameters:
i – int
- Return type: