内容表

上一话题

QIdentityProxyModel

下一话题

QItemSelectionModel

QItemSelection

QItemSelection class manages information about selected items in a model. 更多

Inheritance diagram of PySide2.QtCore.QItemSelection

概要

函数

静态函数

详细描述

A QItemSelection describes the items in a model that have been selected by the user. A QItemSelection is basically a list of selection ranges, see QItemSelectionRange . It provides functions for creating and manipulating selections, and selecting a range of items from a model.

QItemSelection class 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 the topLeft , and ending at the bottomRight .

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)
											

QItemSelection saves 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. Use split() to split one selection range into smaller ranges based on a another selection range.

class QItemSelection

QItemSelection(QItemSelection)

QItemSelection(topLeft, bottomRight)

param QItemSelection

QItemSelection

param topLeft

QModelIndex

param bottomRight

QModelIndex

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 )
参数

t QItemSelectionRange

PySide2.QtCore.QItemSelection. append ( t )
参数

t

PySide2.QtCore.QItemSelection. at ( i )
参数

i int

返回类型

QItemSelectionRange

PySide2.QtCore.QItemSelection. back ( )
返回类型

QItemSelectionRange

PySide2.QtCore.QItemSelection. clear ( )
PySide2.QtCore.QItemSelection. constFirst ( )
返回类型

QItemSelectionRange

PySide2.QtCore.QItemSelection. constLast ( )
返回类型

QItemSelectionRange

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 )
参数

t QItemSelectionRange

返回类型

int

PySide2.QtCore.QItemSelection. detachShared ( )
PySide2.QtCore.QItemSelection. empty ( )
返回类型

bool

PySide2.QtCore.QItemSelection. endsWith ( t )
参数

t QItemSelectionRange

返回类型

bool

PySide2.QtCore.QItemSelection. first ( )
返回类型

QItemSelectionRange

static PySide2.QtCore.QItemSelection. fromSet ( set )
参数

set

返回类型

注意

此函数被弃用。

static PySide2.QtCore.QItemSelection. fromVector ( vector )
参数

vector

返回类型

PySide2.QtCore.QItemSelection. front ( )
返回类型

QItemSelectionRange

PySide2.QtCore.QItemSelection. indexOf ( t [ , from=0 ] )
参数
返回类型

int

PySide2.QtCore.QItemSelection. indexes ( )
返回类型

QModelIndexList

Returns a list of model indexes that correspond to the selected items.

PySide2.QtCore.QItemSelection. insert ( i , t )
参数
PySide2.QtCore.QItemSelection. isEmpty ( )
返回类型

bool

PySide2.QtCore.QItemSelection. isSharedWith ( other )
参数

other

返回类型

bool

PySide2.QtCore.QItemSelection. last ( )
返回类型

QItemSelectionRange

PySide2.QtCore.QItemSelection. lastIndexOf ( t [ , from=-1 ] )
参数
返回类型

int

PySide2.QtCore.QItemSelection. length ( )
返回类型

int

PySide2.QtCore.QItemSelection. merge ( other , command )
参数

Merges the other selection with this QItemSelection 使用 command given. This method guarantees that no ranges are overlapping.

Note that only 选择 , Deselect ,和 Toggle are supported.

另请参阅

split()

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 )
参数

t QItemSelectionRange

返回类型

PySide2.QtCore.QItemSelection. __iadd__ ( l )
参数

l

返回类型

PySide2.QtCore.QItemSelection. __lshift__ ( t )
参数

t QItemSelectionRange

返回类型

PySide2.QtCore.QItemSelection. __lshift__ ( l )
参数

l

返回类型

PySide2.QtCore.QItemSelection. __eq__ ( l )
参数

l

返回类型

bool

PySide2.QtCore.QItemSelection.operator[](i)
参数

i int

返回类型

QItemSelectionRange

PySide2.QtCore.QItemSelection. pop_back ( )
PySide2.QtCore.QItemSelection. pop_front ( )
PySide2.QtCore.QItemSelection. prepend ( t )
参数

t QItemSelectionRange

PySide2.QtCore.QItemSelection. push_back ( t )
参数

t QItemSelectionRange

PySide2.QtCore.QItemSelection. push_front ( t )
参数

t QItemSelectionRange

PySide2.QtCore.QItemSelection. removeAll ( t )
参数

t QItemSelectionRange

返回类型

int

PySide2.QtCore.QItemSelection. removeAt ( i )
参数

i int

PySide2.QtCore.QItemSelection. removeFirst ( )
PySide2.QtCore.QItemSelection. removeLast ( )
PySide2.QtCore.QItemSelection. removeOne ( t )
参数

t QItemSelectionRange

返回类型

bool

PySide2.QtCore.QItemSelection. replace ( i , t )
参数
PySide2.QtCore.QItemSelection. reserve ( size )
参数

size int

PySide2.QtCore.QItemSelection. select ( topLeft , bottomRight )
参数

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

static PySide2.QtCore.QItemSelection. split ( range , other , result )
参数

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.

另请参阅

merge()

PySide2.QtCore.QItemSelection. startsWith ( t )
参数

t QItemSelectionRange

返回类型

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

返回类型

QItemSelectionRange

PySide2.QtCore.QItemSelection. takeFirst ( )
返回类型

QItemSelectionRange

PySide2.QtCore.QItemSelection. takeLast ( )
返回类型

QItemSelectionRange

PySide2.QtCore.QItemSelection. toSet ( )
返回类型

注意

此函数被弃用。

PySide2.QtCore.QItemSelection. toVector ( )
返回类型

PySide2.QtCore.QItemSelection. value ( i )
参数

i int

返回类型

QItemSelectionRange

PySide2.QtCore.QItemSelection. value ( i , defaultValue )
参数
返回类型

QItemSelectionRange