QItemSelectionclass manages information about selected items in a model. 更多 …
def
__add__
(l)
def
__eq__
(l)
def
__iadd__
(l)
def
__iadd__
(t)
def
__lshift__
(l)
def
__lshift__
(t)
def
__ne__
(l)
def
append
(t)
def
append
(t)
def
at
(i)
def
back
()
def
clear
()
def
constFirst
()
def
constLast
()
def
contains
(index)
def
count
()
def
count
(t)
def
detachShared
()
def
empty
()
def
endsWith
(t)
def
first
()
def
front
()
def
indexOf
(t[, from=0])
def
indexes
()
def
insert
(i, t)
def
isEmpty
()
def
isSharedWith
(other)
def
last
()
def
lastIndexOf
(t[, from=-1])
def
length
()
def
merge
(other, command)
def
mid
(pos[, length=-1])
def
move
(from, to)
def
operator[]
(i)
def
pop_back
()
def
pop_front
()
def
prepend
(t)
def
push_back
(t)
def
push_front
(t)
def
removeAll
(t)
def
removeAt
(i)
def
removeFirst
()
def
removeLast
()
def
removeOne
(t)
def
replace
(i, t)
def
reserve
(size)
def
select
(topLeft, bottomRight)
def
setSharable
(sharable)
def
size
()
def
startsWith
(t)
def
swap
(i, j)
def
swap
(other)
def
swapItemsAt
(i, j)
def
takeAt
(i)
def
takeFirst
()
def
takeLast
()
def
toSet
()
def
toVector
()
def
value
(i)
def
value
(i, defaultValue)
def
fromSet
(set)
def
fromVector
(vector)
def
split
(range, other, result)
A
QItemSelectiondescribes the items in a model that have been selected by the user. AQItemSelectionis basically a list of selection ranges, seeQItemSelectionRange. It provides functions for creating and manipulating selections, and selecting a range of items from a model.
QItemSelectionclass is one of the 模型/视图类 and is part of Qt’s 模型/视图框架 .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 thetopLeft, and ending at thebottomRight.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)
QItemSelectionsaves 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.使用
merge()to merge one item selection into another without making overlapping ranges. Usesplit()to split one selection range into smaller ranges based on a another selection range.
QItemSelection
¶
QItemSelection(QItemSelection)
QItemSelection(topLeft, bottomRight)
- param QItemSelection
- param topLeft
- param bottomRight
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
.
PySide2.QtCore.QItemSelection.
append
(
t
)
¶
PySide2.QtCore.QItemSelection.
append
(
t
)
¶
t –
PySide2.QtCore.QItemSelection.
at
(
i
)
¶
i
–
int
PySide2.QtCore.QItemSelection.
back
(
)
¶
PySide2.QtCore.QItemSelection.
clear
(
)
¶
PySide2.QtCore.QItemSelection.
constFirst
(
)
¶
PySide2.QtCore.QItemSelection.
constLast
(
)
¶
PySide2.QtCore.QItemSelection.
contains
(
index
)
¶
index
–
QModelIndex
bool
返回
true
if the selection contains the given
index
;否则返回
false
.
PySide2.QtCore.QItemSelection.
count
(
)
¶
int
PySide2.QtCore.QItemSelection.
count
(
t
)
¶
int
PySide2.QtCore.QItemSelection.
empty
(
)
¶
bool
PySide2.QtCore.QItemSelection.
endsWith
(
t
)
¶
bool
PySide2.QtCore.QItemSelection.
first
(
)
¶
PySide2.QtCore.QItemSelection.
fromSet
(
set
)
¶
set –
注意
此函数被弃用。
PySide2.QtCore.QItemSelection.
fromVector
(
vector
)
¶
vector –
PySide2.QtCore.QItemSelection.
front
(
)
¶
PySide2.QtCore.QItemSelection.
indexOf
(
t
[
,
from=0
]
)
¶
from
–
int
int
PySide2.QtCore.QItemSelection.
indexes
(
)
¶
QModelIndexList
Returns a list of model indexes that correspond to the selected items.
PySide2.QtCore.QItemSelection.
insert
(
i
,
t
)
¶
i
–
int
PySide2.QtCore.QItemSelection.
isEmpty
(
)
¶
bool
other –
bool
PySide2.QtCore.QItemSelection.
last
(
)
¶
PySide2.QtCore.QItemSelection.
lastIndexOf
(
t
[
,
from=-1
]
)
¶
from
–
int
int
PySide2.QtCore.QItemSelection.
length
(
)
¶
int
PySide2.QtCore.QItemSelection.
merge
(
other
,
command
)
¶
other
–
QItemSelection
command
–
SelectionFlags
Merges the
other
selection with this
QItemSelection
使用
command
given. This method guarantees that no ranges are overlapping.
Note that only
选择
,
Deselect
,和
Toggle
are supported.
另请参阅
PySide2.QtCore.QItemSelection.
mid
(
pos
[
,
length=-1
]
)
¶
pos
–
int
length
–
int
PySide2.QtCore.QItemSelection.
move
(
from
,
to
)
¶
from
–
int
to
–
int
PySide2.QtCore.QItemSelection.
__ne__
(
l
)
¶
l –
bool
PySide2.QtCore.QItemSelection.
__add__
(
l
)
¶
l –
PySide2.QtCore.QItemSelection.
__iadd__
(
t
)
¶
PySide2.QtCore.QItemSelection.
__iadd__
(
l
)
¶
l –
PySide2.QtCore.QItemSelection.
__lshift__
(
t
)
¶
PySide2.QtCore.QItemSelection.
__lshift__
(
l
)
¶
l –
PySide2.QtCore.QItemSelection.
__eq__
(
l
)
¶
l –
bool
PySide2.QtCore.QItemSelection.operator[](i)
i
–
int
PySide2.QtCore.QItemSelection.
pop_back
(
)
¶
PySide2.QtCore.QItemSelection.
pop_front
(
)
¶
PySide2.QtCore.QItemSelection.
prepend
(
t
)
¶
PySide2.QtCore.QItemSelection.
push_back
(
t
)
¶
PySide2.QtCore.QItemSelection.
push_front
(
t
)
¶
PySide2.QtCore.QItemSelection.
removeAll
(
t
)
¶
int
PySide2.QtCore.QItemSelection.
removeAt
(
i
)
¶
i
–
int
PySide2.QtCore.QItemSelection.
removeFirst
(
)
¶
PySide2.QtCore.QItemSelection.
removeLast
(
)
¶
PySide2.QtCore.QItemSelection.
removeOne
(
t
)
¶
bool
PySide2.QtCore.QItemSelection.
replace
(
i
,
t
)
¶
i
–
int
PySide2.QtCore.QItemSelection.
reserve
(
size
)
¶
size
–
int
PySide2.QtCore.QItemSelection.
select
(
topLeft
,
bottomRight
)
¶
topLeft
–
QModelIndex
bottomRight
–
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.
注意
topLeft
and
bottomRight
must have the same parent.
PySide2.QtCore.QItemSelection.
setSharable
(
sharable
)
¶
sharable
–
bool
PySide2.QtCore.QItemSelection.
size
(
)
¶
int
PySide2.QtCore.QItemSelection.
split
(
range
,
other
,
result
)
¶
range
–
QItemSelectionRange
other
–
QItemSelectionRange
result
–
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.
另请参阅
PySide2.QtCore.QItemSelection.
startsWith
(
t
)
¶
bool
PySide2.QtCore.QItemSelection.
swap
(
i
,
j
)
¶
i
–
int
j
–
int
注意
此函数被弃用。
PySide2.QtCore.QItemSelection.
swap
(
other
)
¶
other –
PySide2.QtCore.QItemSelection.
swapItemsAt
(
i
,
j
)
¶
i
–
int
j
–
int
PySide2.QtCore.QItemSelection.
takeAt
(
i
)
¶
i
–
int
PySide2.QtCore.QItemSelection.
takeFirst
(
)
¶
PySide2.QtCore.QItemSelection.
takeLast
(
)
¶
PySide2.QtCore.QItemSelection.
toSet
(
)
¶
注意
此函数被弃用。
PySide2.QtCore.QItemSelection.
toVector
(
)
¶
PySide2.QtCore.QItemSelection.
value
(
i
)
¶
i
–
int
PySide2.QtCore.QItemSelection.
value
(
i
,
defaultValue
)
¶
i
–
int
defaultValue
–
QItemSelectionRange