PySide6.QtCore.QItemSelectionRange¶
- class QItemSelectionRange¶
QItemSelectionRange类管理模型中选定项目范围的信息。更多…概要¶
方法¶
def
__init__()def
bottom()def
bottomRight()def
contains()def
height()def
indexes()def
intersected()def
intersects()def
isEmpty()def
isValid()def
left()def
model()def
__ne__()def
__eq__()def
parent()def
right()def
swap()def
top()def
topLeft()def
width()
注意
本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。
详细描述¶
一个
QItemSelectionRange包含有关模型中选定项目范围的信息。项目范围是模型项目的连续数组,扩展到覆盖具有共同父项目的多个相邻行和列;这可以可视化为表格中的二维单元格块。选择范围具有top()、left()、bottom()、right()和parent()。QItemSelectionRange类是模型/视图类之一,是 Qt 模型/视图框架的一部分。可以使用
indexes()函数获取选择范围内包含的模型项。使用selectedIndexes()可以获取视图中所有选定项的列表。您可以通过使用
contains()函数来确定给定的模型项是否位于特定范围内。范围也可以使用重载的相等和不相等运算符进行比较,而intersects()函数允许您确定两个范围是否重叠。- __init__()¶
构造一个空的选择范围。
- __init__(index)
- Parameters:
索引 –
QModelIndex
构造一个新的选择范围,仅包含由模型索引
index指定的模型项。- __init__(topL, bottomR)
- Parameters:
topL –
QModelIndexbottomR –
QModelIndex
构造一个新的选择范围,仅包含由
topLeft指定的索引和索引bottomRight。- bottom()¶
- Return type:
整数
返回与选择范围内最下方选定行对应的行索引。
- bottomRight()¶
- Return type:
返回位于选择范围右下角的项目的索引。
- contains(index)¶
- Parameters:
索引 –
QModelIndex- Return type:
布尔
如果由
index指定的模型项位于选定项的范围内,则返回true;否则返回false。- contains(row, column, parentIndex)
- Parameters:
row – int
column – 整数
parentIndex –
QModelIndex
- Return type:
布尔
这是一个重载函数。
如果由 (
row,column) 指定的模型项以及以parentIndex作为父项的项位于选定项的范围内,则返回true;否则返回false。- height()¶
- Return type:
整数
返回选择范围内选中的行数。
- indexes()¶
- Return type:
QModelIndex 的列表
返回存储在选中的模型索引项列表。
- intersected(other)¶
- Parameters:
其他 –
QItemSelectionRange- Return type:
返回一个新的选择范围,仅包含在选择范围和
other选择范围中都找到的项目。- intersects(other)¶
- Parameters:
其他 –
QItemSelectionRange- Return type:
布尔
如果此选择范围与给定的
other范围相交(重叠),则返回true;否则返回false。- isEmpty()¶
- Return type:
布尔
如果选择范围不包含任何项目或仅包含被禁用或标记为不可选择的项目,则返回
true。- isValid()¶
- Return type:
布尔
如果选择范围有效,则返回
true;否则返回false。- left()¶
- Return type:
整数
返回与选择范围中最左侧选定的列对应的列索引。
- model()¶
- Return type:
返回选择范围内的项目所属的模型。
- __ne__(rhs)¶
- Parameters:
rhs –
QItemSelectionRange- Return type:
布尔
如果
lhs选择范围与给定的rhs范围不同,则返回true;否则返回false。- __eq__(rhs)¶
- Parameters:
rhs –
QItemSelectionRange- Return type:
布尔
如果
lhs选择范围与给定的rhs范围完全相同,则返回true;否则返回false。- parent()¶
- Return type:
返回选择范围内项的父模型项索引。
- right()¶
- Return type:
整数
返回与选择范围中最右侧选中的列对应的列索引。
- swap(other)¶
- Parameters:
其他 –
QItemSelectionRange
将此选择范围的内容与
other交换。此函数非常快速且永远不会失败。- top()¶
- Return type:
整数
返回与选择范围中最上方选定行对应的行索引。
- topLeft()¶
- Return type:
返回位于选择范围左上角的项目的索引。
另请参阅
- width()¶
- Return type:
整数
返回选择范围内所选列的数量。