QItemSelection#
The QItemSelection
class manages information about selected items in a model. More…
Synopsis#
Functions#
def
append
(l)def
append
(arg__1)def
at
(i)def
back
()def
capacity
()def
clear
()def
constData
()def
constFirst
()def
constLast
()def
contains
(index)def
count
()def
data
()def
empty
()def
first
()def
first
(n)def
front
()def
indexes
()def
insert
(arg__1, arg__2)def
isEmpty
()def
isSharedWith
(other)def
last
()def
last
(n)def
length
()def
merge
(other, command)def
mid
(pos[, len=-1])def
move
(from, to)def
__ne__
(arg__1)def
__add__
(arg__1)def
__iadd__
(l)def
__lshift__
(l)def
__eq__
(arg__1)def
operator[]
(i)def
pop_back
()def
pop_front
()def
prepend
(arg__1)def
push_back
(arg__1)def
push_front
(arg__1)def
remove
(i[, n=1])def
removeAll
(arg__1)def
removeAt
(i)def
removeFirst
()def
removeLast
()def
removeOne
(arg__1)def
reserve
(size)def
resize
(size)def
select
(topLeft, bottomRight)def
shrink_to_fit
()def
size
()def
sliced
(pos)def
sliced
(pos, n)def
squeeze
()def
swap
(other)def
swapItemsAt
(i, j)def
takeAt
(i)def
toList
()def
toVector
()def
value
(i)
Static functions#
def
fromList
(list)def
fromVector
(vector)def
split
(range, other, result)
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. A QItemSelection
is basically a list of selection ranges, see QItemSelectionRange
. 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 the topLeft
, and ending at the bottomRight
.
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. Use split()
to split one selection range into smaller ranges based on a another selection range.
- class PySide6.QtCore.QItemSelection#
PySide6.QtCore.QItemSelection(topLeft, bottomRight)
- Parameters:
topLeft –
PySide6.QtCore.QModelIndex
bottomRight –
PySide6.QtCore.QModelIndex
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 by bottomRight
.
- PySide6.QtCore.QItemSelection.append(l)#
- Parameters:
l –
- PySide6.QtCore.QItemSelection.append(arg__1)
- Parameters:
arg__1 –
PySide6.QtCore.QItemSelectionRange
- PySide6.QtCore.QItemSelection.at(i)#
- Parameters:
i –
qsizetype
- Return type:
- PySide6.QtCore.QItemSelection.back()#
- Return type:
- PySide6.QtCore.QItemSelection.capacity()#
- Return type:
qsizetype
- PySide6.QtCore.QItemSelection.clear()#
- PySide6.QtCore.QItemSelection.constData()#
- Return type:
- PySide6.QtCore.QItemSelection.constFirst()#
- Return type:
- PySide6.QtCore.QItemSelection.constLast()#
- Return type:
- PySide6.QtCore.QItemSelection.contains(index)#
- Parameters:
index –
PySide6.QtCore.QModelIndex
- Return type:
bool
Returns true
if the selection contains the given index
; otherwise returns false
.
- PySide6.QtCore.QItemSelection.count()#
- Return type:
qsizetype
- PySide6.QtCore.QItemSelection.data()#
- Return type:
- PySide6.QtCore.QItemSelection.empty()#
- Return type:
bool
- PySide6.QtCore.QItemSelection.first()#
- Return type:
- PySide6.QtCore.QItemSelection.first(n)
- Parameters:
n –
qsizetype
- static PySide6.QtCore.QItemSelection.fromList(list)#
- Parameters:
list –
- static PySide6.QtCore.QItemSelection.fromVector(vector)#
- Parameters:
vector –
- PySide6.QtCore.QItemSelection.front()#
- Return type:
- PySide6.QtCore.QItemSelection.indexes()#
Returns a list of model indexes that correspond to the selected items.
- PySide6.QtCore.QItemSelection.insert(arg__1, arg__2)#
- Parameters:
arg__1 –
qsizetype
arg__2 –
PySide6.QtCore.QItemSelectionRange
- PySide6.QtCore.QItemSelection.isEmpty()#
- Return type:
bool
- Parameters:
other –
- Return type:
bool
- PySide6.QtCore.QItemSelection.last()#
- Return type:
- PySide6.QtCore.QItemSelection.last(n)
- Parameters:
n –
qsizetype
- PySide6.QtCore.QItemSelection.length()#
- Return type:
qsizetype
- PySide6.QtCore.QItemSelection.merge(other, command)#
- Parameters:
other –
PySide6.QtCore.QItemSelection
command –
SelectionFlags
Merges the other
selection with this QItemSelection
using the command
given. This method guarantees that no ranges are overlapping.
Note that only Select
, Deselect
, and Toggle
are supported.
See also
- PySide6.QtCore.QItemSelection.mid(pos[, len=-1])#
- Parameters:
pos –
qsizetype
len –
qsizetype
- PySide6.QtCore.QItemSelection.move(from, to)#
- Parameters:
from –
qsizetype
to –
qsizetype
- PySide6.QtCore.QItemSelection.__ne__(arg__1)#
- Parameters:
arg__1 –
PySide6.QtCore.QItemSelection
- Return type:
bool
- PySide6.QtCore.QItemSelection.__add__(arg__1)#
- Parameters:
arg__1 –
PySide6.QtCore.QItemSelection
- Return type:
- PySide6.QtCore.QItemSelection.__iadd__(l)#
- Parameters:
l –
- PySide6.QtCore.QItemSelection.__lshift__(l)#
- Parameters:
l –
- PySide6.QtCore.QItemSelection.__eq__(arg__1)#
- Parameters:
arg__1 –
PySide6.QtCore.QItemSelection
- Return type:
bool
- PySide6.QtCore.QItemSelection.operator[](i)
- Parameters:
i –
qsizetype
- Return type:
- PySide6.QtCore.QItemSelection.pop_back()#
- PySide6.QtCore.QItemSelection.pop_front()#
- PySide6.QtCore.QItemSelection.prepend(arg__1)#
- Parameters:
arg__1 –
PySide6.QtCore.QItemSelectionRange
- PySide6.QtCore.QItemSelection.push_back(arg__1)#
- Parameters:
arg__1 –
PySide6.QtCore.QItemSelectionRange
- PySide6.QtCore.QItemSelection.push_front(arg__1)#
- Parameters:
arg__1 –
PySide6.QtCore.QItemSelectionRange
- PySide6.QtCore.QItemSelection.remove(i[, n=1])#
- Parameters:
i –
qsizetype
n –
qsizetype
- PySide6.QtCore.QItemSelection.removeAll(arg__1)#
- Parameters:
arg__1 –
PySide6.QtCore.QItemSelectionRange
- PySide6.QtCore.QItemSelection.removeAt(i)#
- Parameters:
i –
qsizetype
- PySide6.QtCore.QItemSelection.removeFirst()#
- PySide6.QtCore.QItemSelection.removeLast()#
- PySide6.QtCore.QItemSelection.removeOne(arg__1)#
- Parameters:
arg__1 –
PySide6.QtCore.QItemSelectionRange
- PySide6.QtCore.QItemSelection.reserve(size)#
- Parameters:
size –
qsizetype
- PySide6.QtCore.QItemSelection.resize(size)#
- Parameters:
size –
qsizetype
- PySide6.QtCore.QItemSelection.select(topLeft, bottomRight)#
- Parameters:
topLeft –
PySide6.QtCore.QModelIndex
bottomRight –
PySide6.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 by bottomRight
to the list.
Note
topLeft
and bottomRight
must have the same parent.
- PySide6.QtCore.QItemSelection.shrink_to_fit()#
- PySide6.QtCore.QItemSelection.size()#
- Return type:
qsizetype
- PySide6.QtCore.QItemSelection.sliced(pos)#
- Parameters:
pos –
qsizetype
- PySide6.QtCore.QItemSelection.sliced(pos, n)
- Parameters:
pos –
qsizetype
n –
qsizetype
- static PySide6.QtCore.QItemSelection.split(range, other, result)#
- Parameters:
result –
PySide6.QtCore.QItemSelection
Splits the selection range
using the selection other
range. Removes all items in other
from range
and puts the result in result
. This can be compared with the semantics of the subtract operation of a set.
See also
- PySide6.QtCore.QItemSelection.squeeze()#
- PySide6.QtCore.QItemSelection.swap(other)#
- Parameters:
other –
- PySide6.QtCore.QItemSelection.swapItemsAt(i, j)#
- Parameters:
i –
qsizetype
j –
qsizetype
- PySide6.QtCore.QItemSelection.takeAt(i)#
- Parameters:
i –
qsizetype
- Return type:
- PySide6.QtCore.QItemSelection.toList()#
- PySide6.QtCore.QItemSelection.toVector()#
- PySide6.QtCore.QItemSelection.value(i)#
- Parameters:
i –
qsizetype
- Return type: