PySide6.QtCore.QItemSelection¶
- class QItemSelection¶
QItemSelection类管理模型中选定项目的信息。更多…概要¶
方法¶
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
max_size()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()
静态函数¶
def
fromList()def
fromVector()def
maxSize()def
split()
注意
本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。
详细描述¶
警告
本节包含从C++自动翻译到Python的代码片段,可能包含错误。
一个
QItemSelection描述了用户选择的模型中的项目。QItemSelection基本上是一个选择范围的列表,参见QItemSelectionRange。它提供了创建和操作选择以及从模型中选择一系列项目的函数。QItemSelection类是模型/视图类之一,是 Qt 模型/视图框架的一部分。可以构建并初始化一个项目选择,以包含来自现有模型的一系列项目。以下示例构建了一个选择,该选择包含来自给定
model的一系列项目,从topLeft开始,到bottomRight结束。selection = QItemSelection(topLeft, bottomRight)
可以构造一个空的项目选择,然后根据需要填充。因此,如果在我们构造项目选择时模型不可用,我们可以用以下方式重写上述代码:
selection = QItemSelection() ... selection.select(topLeft, bottomRight)
QItemSelection通过使用选择范围而不是记录选择中每个项目的模型项目索引来节省内存,并避免不必要的工作。通常,此类的实例将包含一个不重叠的选择范围列表。使用
merge()将一个项目选择合并到另一个项目中,而不会产生重叠范围。使用split()根据另一个选择范围将一个选择范围拆分为更小的范围。另请参阅
- __init__()¶
构造一个空的选择。
- __init__(topLeft, bottomRight)
- Parameters:
topLeft –
QModelIndexbottomRight –
QModelIndex
构造一个项目选择,从左上角的模型项目(由
topLeft索引指定)延伸到右下角的项目(由bottomRight指定)。- append(arg__1)¶
- Parameters:
arg__1 –
QItemSelectionRange
- append(l)
- Parameters:
l – QItemSelectionRange 的列表
- at(i)¶
- Parameters:
i – 整数
- Return type:
- back()¶
- Return type:
- capacity()¶
- Return type:
整数
- clear()¶
- constData()¶
- Return type:
- constFirst()¶
- Return type:
- constLast()¶
- Return type:
- contains(index)¶
- Parameters:
索引 –
QModelIndex- Return type:
布尔
如果选择包含给定的
index,则返回true;否则返回false。- count()¶
- Return type:
整数
- data()¶
- Return type:
- empty()¶
- Return type:
布尔
- first()¶
- Return type:
- first(n)
- Parameters:
n – 整数
- Return type:
- static fromList(list)¶
- Parameters:
列表 – QItemSelectionRange 的列表
- Return type:
.list of QItemSelectionRange
- static fromVector(vector)¶
- Parameters:
vector – QItemSelectionRange 的列表
- Return type:
- front()¶
- Return type:
- indexes()¶
- Return type:
QModelIndex 的列表
返回与所选项目对应的模型索引列表。
- insert(arg__1, arg__2)¶
- Parameters:
arg__1 – 整数
arg__2 –
QItemSelectionRange
- isEmpty()¶
- Return type:
布尔
- Parameters:
其他 – .QItemSelectionRange 的列表
- Return type:
布尔
- last()¶
- Return type:
- last(n)
- Parameters:
n – 整数
- Return type:
.list of QItemSelectionRange
- length()¶
- Return type:
整数
- static maxSize()¶
- Return type:
整数
- max_size()¶
- Return type:
整数
- merge(other, command)¶
- Parameters:
其他 –
QItemSelectioncommand –
SelectionFlag的组合
使用给定的
command将other选择与这个QItemSelection合并。此方法确保没有范围重叠。请注意,仅支持
Select、Deselect和Toggle。另请参阅
- mid(pos[, len=-1])¶
- Parameters:
pos – 整数
len – int
- Return type:
- move(from, to)¶
- Parameters:
from – 整数
to – int
- __ne__(arg__1)¶
- Parameters:
arg__1 –
QItemSelection- Return type:
布尔
- __add__(arg__1)¶
- Parameters:
arg__1 –
QItemSelection- Return type:
- __iadd__(l)¶
- Parameters:
l – QItemSelectionRange 的列表
- Return type:
- __lshift__(l)¶
- Parameters:
l – QItemSelectionRange 的列表
- Return type:
- __eq__(arg__1)¶
- Parameters:
arg__1 –
QItemSelection- Return type:
布尔
- operator(i)¶
- Parameters:
i – 整数
- 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 – 整数
n – 整数
- removeAll(arg__1)¶
- Parameters:
arg__1 –
QItemSelectionRange
- removeAt(i)¶
- Parameters:
i – 整数
- removeFirst()¶
- removeLast()¶
- removeOne(arg__1)¶
- Parameters:
arg__1 –
QItemSelectionRange
- reserve(size)¶
- Parameters:
size – int
- resize(size)¶
- Parameters:
size – int
- resizeForOverwrite(size)¶
- Parameters:
size – int
- select(topLeft, bottomRight)¶
- Parameters:
topLeft –
QModelIndexbottomRight –
QModelIndex
将范围中的项目添加到列表中,该范围从左上角的模型项目(由
topLeft索引指定)延伸到右下角的项目(由bottomRight指定)。注意
topLeft和bottomRight必须具有相同的父级。- shrink_to_fit()¶
- size()¶
- Return type:
整数
- sliced(pos)¶
- Parameters:
pos – 整数
- Return type:
- sliced(pos, n)
- Parameters:
pos – 整数
n – 整数
- Return type:
- static split(range, other, result)¶
- Parameters:
range –
QItemSelectionRange其他 –
QItemSelectionRange结果 –
QItemSelection
使用选择范围
other来分割选择范围range。从range中移除所有在other中的项,并将结果放入result。这可以与集合的减法操作的语义进行比较。另请参阅
- squeeze()¶
- swap(other)¶
- Parameters:
其他 – .QItemSelectionRange 的列表
- swapItemsAt(i, j)¶
- Parameters:
i – 整数
j – int
- takeAt(i)¶
- Parameters:
i – 整数
- Return type:
- toList()¶
- Return type:
- toVector()¶
- Return type:
- value(i)¶
- Parameters:
i – 整数
- Return type: