QItemSelection¶
The
QItemSelection
class manages information about selected items in a model. More…
Synopsis¶
Functions¶
def
__add__
(l)def
__eq__
(l)def
__iadd__
(l)def
__iadd__
(t)def
__lshift__
(l)def
__lshift__
(t)def
__ne__
(l)def
append
(t)def
append
(t)def
at
(i)def
back
()def
clear
()def
constFirst
()def
constLast
()def
contains
(index)def
count
()def
count
(t)def
detachShared
()def
empty
()def
endsWith
(t)def
first
()def
front
()def
indexOf
(t[, from=0])def
indexes
()def
insert
(i, t)def
isEmpty
()def
isSharedWith
(other)def
last
()def
lastIndexOf
(t[, from=-1])def
length
()def
merge
(other, command)def
mid
(pos[, length=-1])def
move
(from, to)def
operator[]
(i)def
pop_back
()def
pop_front
()def
prepend
(t)def
push_back
(t)def
push_front
(t)def
removeAll
(t)def
removeAt
(i)def
removeFirst
()def
removeLast
()def
removeOne
(t)def
replace
(i, t)def
reserve
(size)def
select
(topLeft, bottomRight)def
setSharable
(sharable)def
size
()def
startsWith
(t)def
swap
(i, j)def
swap
(other)def
swapItemsAt
(i, j)def
takeAt
(i)def
takeFirst
()def
takeLast
()def
toSet
()def
toVector
()def
value
(i)def
value
(i, defaultValue)
Static functions¶
def
fromSet
(set)def
fromVector
(vector)def
split
(range, other, result)
Detailed Description¶
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.
- class PySide2.QtCore.QItemSelection¶
PySide2.QtCore.QItemSelection(QItemSelection)
PySide2.QtCore.QItemSelection(topLeft, bottomRight)
- param QItemSelection:
- param topLeft:
- param bottomRight:
Constructs an empty selection.
Constructs an item selection that extends from the top-left model item, specified by the
topLeft
index, to the bottom-right item, specified bybottomRight
.
- PySide2.QtCore.QItemSelection.append(t)¶
- Parameters:
- PySide2.QtCore.QItemSelection.append(t)
- Parameters:
t –
- PySide2.QtCore.QItemSelection.at(i)¶
- Parameters:
i – int
- Return type:
- PySide2.QtCore.QItemSelection.back()¶
- Return type:
- PySide2.QtCore.QItemSelection.clear()¶
- PySide2.QtCore.QItemSelection.constFirst()¶
- Return type:
- PySide2.QtCore.QItemSelection.constLast()¶
- Return type:
- PySide2.QtCore.QItemSelection.contains(index)¶
- Parameters:
index –
PySide2.QtCore.QModelIndex
- Return type:
bool
Returns
true
if the selection contains the givenindex
; otherwise returnsfalse
.
- PySide2.QtCore.QItemSelection.count()¶
- Return type:
int
- PySide2.QtCore.QItemSelection.count(t)
- Parameters:
- Return type:
int
- PySide2.QtCore.QItemSelection.empty()¶
- Return type:
bool
- PySide2.QtCore.QItemSelection.endsWith(t)¶
- Parameters:
- Return type:
bool
- PySide2.QtCore.QItemSelection.first()¶
- Return type:
- static PySide2.QtCore.QItemSelection.fromSet(set)¶
- Parameters:
set –
- Return type:
Note
This function is deprecated.
- static PySide2.QtCore.QItemSelection.fromVector(vector)¶
- Parameters:
vector –
- Return type:
- PySide2.QtCore.QItemSelection.front()¶
- Return type:
- PySide2.QtCore.QItemSelection.indexOf(t[, from=0])¶
- Parameters:
from – int
- Return type:
int
- PySide2.QtCore.QItemSelection.indexes()¶
- Return type:
QModelIndexList
Returns a list of model indexes that correspond to the selected items.
- PySide2.QtCore.QItemSelection.insert(i, t)¶
- Parameters:
i – int
- PySide2.QtCore.QItemSelection.isEmpty()¶
- Return type:
bool
- Parameters:
other –
- Return type:
bool
- PySide2.QtCore.QItemSelection.last()¶
- Return type:
- PySide2.QtCore.QItemSelection.lastIndexOf(t[, from=-1])¶
- Parameters:
from – int
- Return type:
int
- PySide2.QtCore.QItemSelection.length()¶
- Return type:
int
- PySide2.QtCore.QItemSelection.merge(other, command)¶
- Parameters:
other –
PySide2.QtCore.QItemSelection
command –
SelectionFlags
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
- PySide2.QtCore.QItemSelection.mid(pos[, length=-1])¶
- Parameters:
pos – int
length – int
- Return type:
- PySide2.QtCore.QItemSelection.move(from, to)¶
- Parameters:
from – int
to – int
- PySide2.QtCore.QItemSelection.__ne__(l)¶
- Parameters:
l –
- Return type:
bool
- PySide2.QtCore.QItemSelection.__add__(l)¶
- Parameters:
l –
- Return type:
- PySide2.QtCore.QItemSelection.__iadd__(t)¶
- Parameters:
- Return type:
- PySide2.QtCore.QItemSelection.__iadd__(l)
- Parameters:
l –
- Return type:
- PySide2.QtCore.QItemSelection.__lshift__(t)¶
- Parameters:
- Return type:
- PySide2.QtCore.QItemSelection.__lshift__(l)
- Parameters:
l –
- Return type:
- PySide2.QtCore.QItemSelection.__eq__(l)¶
- Parameters:
l –
- Return type:
bool
- PySide2.QtCore.QItemSelection.operator[](i)
- Parameters:
i – int
- Return type:
- PySide2.QtCore.QItemSelection.pop_back()¶
- PySide2.QtCore.QItemSelection.pop_front()¶
- PySide2.QtCore.QItemSelection.prepend(t)¶
- Parameters:
- PySide2.QtCore.QItemSelection.push_back(t)¶
- Parameters:
- PySide2.QtCore.QItemSelection.push_front(t)¶
- Parameters:
- PySide2.QtCore.QItemSelection.removeAll(t)¶
- Parameters:
- Return type:
int
- PySide2.QtCore.QItemSelection.removeAt(i)¶
- Parameters:
i – int
- PySide2.QtCore.QItemSelection.removeFirst()¶
- PySide2.QtCore.QItemSelection.removeLast()¶
- PySide2.QtCore.QItemSelection.removeOne(t)¶
- Parameters:
- Return type:
bool
- PySide2.QtCore.QItemSelection.replace(i, t)¶
- Parameters:
i – int
- PySide2.QtCore.QItemSelection.reserve(size)¶
- Parameters:
size – int
- PySide2.QtCore.QItemSelection.select(topLeft, bottomRight)¶
- Parameters:
topLeft –
PySide2.QtCore.QModelIndex
bottomRight –
PySide2.QtCore.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.
- PySide2.QtCore.QItemSelection.setSharable(sharable)¶
- Parameters:
sharable – bool
- PySide2.QtCore.QItemSelection.size()¶
- Return type:
int
- static PySide2.QtCore.QItemSelection.split(range, other, result)¶
- Parameters:
result –
PySide2.QtCore.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
- PySide2.QtCore.QItemSelection.startsWith(t)¶
- Parameters:
- Return type:
bool
- PySide2.QtCore.QItemSelection.swap(i, j)¶
- Parameters:
i – int
j – int
Note
This function is deprecated.
- PySide2.QtCore.QItemSelection.swap(other)
- Parameters:
other –
- PySide2.QtCore.QItemSelection.swapItemsAt(i, j)¶
- Parameters:
i – int
j – int
- PySide2.QtCore.QItemSelection.takeAt(i)¶
- Parameters:
i – int
- Return type:
- PySide2.QtCore.QItemSelection.takeFirst()¶
- Return type:
- PySide2.QtCore.QItemSelection.takeLast()¶
- Return type:
- PySide2.QtCore.QItemSelection.toSet()¶
- Return type:
Note
This function is deprecated.
- PySide2.QtCore.QItemSelection.toVector()¶
- Return type:
- PySide2.QtCore.QItemSelection.value(i)¶
- Parameters:
i – int
- Return type:
- PySide2.QtCore.QItemSelection.value(i, defaultValue)
- Parameters:
i – int
defaultValue –
PySide2.QtCore.QItemSelectionRange
- Return type:
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.