QItemSelectionModelclass keeps track of a view’s selected items. 更多 …
def
columnIntersectsSelection
(column[, parent=QModelIndex()])
def
currentIndex
()
def
emitSelectionChanged
(newSelection, oldSelection)
def
hasSelection
()
def
isColumnSelected
(column[, parent=QModelIndex()])
def
isRowSelected
(row[, parent=QModelIndex()])
def
isSelected
(index)
def
model
()
def
rowIntersectsSelection
(row[, parent=QModelIndex()])
def
selectedColumns
([row=0])
def
selectedIndexes
()
def
selectedRows
([column=0])
def
selection
()
def
setModel
(model)
def
clear
()
def
clearCurrentIndex
()
def
reset
()
def
select
(index, command)
def
select
(selection, command)
def
setCurrentIndex
(index, command)
def
clearSelection
()
def
currentChanged
(current, previous)
def
currentColumnChanged
(current, previous)
def
currentRowChanged
(current, previous)
def
modelChanged
(model)
def
selectionChanged
(selected, deselected)
A
QItemSelectionModelkeeps track of the selected items in a view, or in several views onto the same model. It also keeps track of the currently selected item in a view.
QItemSelectionModelclass is one of the 模型/视图类 and is part of Qt’s 模型/视图框架 .选中项使用范围存储。每当想要修改选中项时,使用
select()and provide either aQItemSelection,或QModelIndex和SelectionFlag.
QItemSelectionModeltakes a two layer approach to selection management, dealing with both selected items that have been committed and items that are part of the current selection. The current selected items are part of the current interactive selection (for example with rubber-band selection or keyboard-shift selections).要更新目前的选中项,使用按位 OR 的
Current和任何其它SelectionFlags。若省略Current命令,将创建新的当前选定,并将之前的一个添加到整个选定。所有函数都在 2 层上运转;例如,selecteditems()将从 2 层返回项。注意
从 5.5 起,
model,hasSelection,和currentIndex是元对象特性。
QItemSelectionModel
(
[
model=None
]
)
¶
QItemSelectionModel(model, parent)
- param parent
- param model
Constructs a selection model that operates on the specified item
model
.
Constructs a selection model that operates on the specified item
model
with
parent
.
PySide2.QtCore.QItemSelectionModel.
SelectionFlag
¶
此枚举描述将更新选定模型的方式。
|
常量 |
描述 |
|---|---|
|
QItemSelectionModel.NoUpdate |
No selection will be made. |
|
QItemSelectionModel.Clear |
The complete selection will be cleared. |
|
QItemSelectionModel.Select |
所有指定索引将被选中。 |
|
QItemSelectionModel.Deselect |
所有指定索引将被取消选择。 |
|
QItemSelectionModel.Toggle |
All specified indexes will be selected or deselected depending on their current state. |
|
QItemSelectionModel.Current |
当前选定将被更新。 |
|
QItemSelectionModel.Rows |
将扩展所有索引以跨行。 |
|
QItemSelectionModel.Columns |
将扩展所有索引以跨列。 |
|
QItemSelectionModel.SelectCurrent |
A combination of Select and Current, provided for convenience. |
|
QItemSelectionModel.ToggleCurrent |
A combination of Toggle and Current, provided for convenience. |
|
QItemSelectionModel.ClearAndSelect |
A combination of Clear and Select, provided for convenience. |
PySide2.QtCore.QItemSelectionModel.
clear
(
)
¶
清零选定模型。发射
selectionChanged()
and
currentChanged()
.
PySide2.QtCore.QItemSelectionModel.
clearCurrentIndex
(
)
¶
清零当前索引。发射
currentChanged()
.
PySide2.QtCore.QItemSelectionModel.
clearSelection
(
)
¶
Clears the selection in the selection model. Emits
selectionChanged()
.
PySide2.QtCore.QItemSelectionModel.
columnIntersectsSelection
(
column
[
,
parent=QModelIndex()
]
)
¶
column
–
int
parent
–
QModelIndex
bool
返回
true
若有选中任何项在
column
采用给定
parent
.
注意
从 Qt 5.15 起,默认自变量对于
parent
是空模型索引。
PySide2.QtCore.QItemSelectionModel.
currentChanged
(
current
,
上一
)
¶
current
–
QModelIndex
上一
–
QModelIndex
PySide2.QtCore.QItemSelectionModel.
currentColumnChanged
(
current
,
上一
)
¶
current
–
QModelIndex
上一
–
QModelIndex
PySide2.QtCore.QItemSelectionModel.
currentIndex
(
)
¶
Returns the model item index for the current item, or an invalid index if there is no current item.
另请参阅
PySide2.QtCore.QItemSelectionModel.
currentRowChanged
(
current
,
上一
)
¶
current
–
QModelIndex
上一
–
QModelIndex
PySide2.QtCore.QItemSelectionModel.
emitSelectionChanged
(
newSelection
,
oldSelection
)
¶
newSelection
–
QItemSelection
oldSelection
–
QItemSelection
比较 2 选定
newSelection
and
oldSelection
并发射
selectionChanged()
with the deselected and selected items.
PySide2.QtCore.QItemSelectionModel.
hasSelection
(
)
¶
bool
返回
true
if the selection model contains any selection ranges; otherwise returns
false
.
PySide2.QtCore.QItemSelectionModel.
isColumnSelected
(
column
[
,
parent=QModelIndex()
]
)
¶
column
–
int
parent
–
QModelIndex
bool
返回
true
if all items are selected in the
column
采用给定
parent
.
Note that this function is usually faster than calling
isSelected()
on all items in the same column and that unselectable items are ignored.
注意
从 Qt 5.15 起,默认自变量对于
parent
是空模型索引。
PySide2.QtCore.QItemSelectionModel.
isRowSelected
(
row
[
,
parent=QModelIndex()
]
)
¶
row
–
int
parent
–
QModelIndex
bool
返回
true
if all items are selected in the
row
采用给定
parent
.
Note that this function is usually faster than calling
isSelected()
on all items in the same row and that unselectable items are ignored.
注意
从 Qt 5.15 起,默认自变量对于
parent
是空模型索引。
PySide2.QtCore.QItemSelectionModel.
isSelected
(
index
)
¶
index
–
QModelIndex
bool
返回
true
若给定模型项
index
被选中。
PySide2.QtCore.QItemSelectionModel.
model
(
)
¶
返回由选定模型操作的项模型。
另请参阅
PySide2.QtCore.QItemSelectionModel.
modelChanged
(
model
)
¶
model
–
QAbstractItemModel
PySide2.QtCore.QItemSelectionModel.
reset
(
)
¶
Clears the selection model. Does not emit any signals.
PySide2.QtCore.QItemSelectionModel.
rowIntersectsSelection
(
row
[
,
parent=QModelIndex()
]
)
¶
row
–
int
parent
–
QModelIndex
bool
返回
true
若有选中任何项在
row
采用给定
parent
.
注意
从 Qt 5.15 起,默认自变量对于
parent
是空模型索引。
PySide2.QtCore.QItemSelectionModel.
select
(
index
,
command
)
¶
index
–
QModelIndex
command
–
SelectionFlags
PySide2.QtCore.QItemSelectionModel.
select
(
selection
,
command
)
¶
selection
–
QItemSelection
command
–
SelectionFlags
PySide2.QtCore.QItemSelectionModel.
selectedColumns
(
[
row=0
]
)
¶
row
–
int
QModelIndexList
返回的索引在给定
row
对于选中所有行的列而言。
PySide2.QtCore.QItemSelectionModel.
selectedIndexes
(
)
¶
QModelIndexList
返回所有选中模型项索引的列表。列表包含的不重复,且未排序。
PySide2.QtCore.QItemSelectionModel.
selectedRows
(
[
column=0
]
)
¶
column
–
int
QModelIndexList
返回的索引在给定
column
对于选中所有列的行而言。
PySide2.QtCore.QItemSelectionModel.
selection
(
)
¶
返回存储在选定模型中的选定范围。
PySide2.QtCore.QItemSelectionModel.
selectionChanged
(
selected
,
deselected
)
¶
selected
–
QItemSelection
deselected
–
QItemSelection
PySide2.QtCore.QItemSelectionModel.
setCurrentIndex
(
index
,
command
)
¶
index
–
QModelIndex
command
–
SelectionFlags
Sets the model item
index
to be the current item, and emits
currentChanged()
. The current item is used for keyboard navigation and focus indication; it is independent of any selected items, although a selected item can also be the current item.
从属指定
command
,
index
can also become part of the current selection.
另请参阅
PySide2.QtCore.QItemSelectionModel.
setModel
(
model
)
¶
model
–
QAbstractItemModel
将模型设为
model
。
modelChanged()
signal will be emitted.
另请参阅