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