QItemSelection#

The QItemSelection class manages information about selected items in a model. More

Inheritance diagram of PySide6.QtCore.QItemSelection

Synopsis#

Functions#

Static functions#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

Warning

This section contains snippets that were automatically translated from C++ to Python and may contain errors.

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.

The QItemSelection class is one of the Model/View Classes and is part of Qt’s model/view framework .

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.

Use 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 PySide6.QtCore.QItemSelection#

PySide6.QtCore.QItemSelection(topLeft, bottomRight)

Parameters:

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.

PySide6.QtCore.QItemSelection.append(l)#
Parameters:

l

PySide6.QtCore.QItemSelection.append(arg__1)
Parameters:

arg__1PySide6.QtCore.QItemSelectionRange

PySide6.QtCore.QItemSelection.at(i)#
Parameters:

iqsizetype

Return type:

PySide6.QtCore.QItemSelectionRange

PySide6.QtCore.QItemSelection.back()#
Return type:

PySide6.QtCore.QItemSelectionRange

PySide6.QtCore.QItemSelection.capacity()#
Return type:

qsizetype

PySide6.QtCore.QItemSelection.clear()#
PySide6.QtCore.QItemSelection.constData()#
Return type:

PySide6.QtCore.QItemSelectionRange

PySide6.QtCore.QItemSelection.constFirst()#
Return type:

PySide6.QtCore.QItemSelectionRange

PySide6.QtCore.QItemSelection.constLast()#
Return type:

PySide6.QtCore.QItemSelectionRange

PySide6.QtCore.QItemSelection.contains(index)#
Parameters:

indexPySide6.QtCore.QModelIndex

Return type:

bool

Returns true if the selection contains the given index; otherwise returns false.

PySide6.QtCore.QItemSelection.count()#
Return type:

qsizetype

PySide6.QtCore.QItemSelection.data()#
Return type:

PySide6.QtCore.QItemSelectionRange

PySide6.QtCore.QItemSelection.empty()#
Return type:

bool

PySide6.QtCore.QItemSelection.first()#
Return type:

PySide6.QtCore.QItemSelectionRange

PySide6.QtCore.QItemSelection.first(n)
Parameters:

nqsizetype

static PySide6.QtCore.QItemSelection.fromList(list)#
Parameters:

list

static PySide6.QtCore.QItemSelection.fromVector(vector)#
Parameters:

vector

PySide6.QtCore.QItemSelection.front()#
Return type:

PySide6.QtCore.QItemSelectionRange

PySide6.QtCore.QItemSelection.indexes()#

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

PySide6.QtCore.QItemSelection.insert(arg__1, arg__2)#
Parameters:
PySide6.QtCore.QItemSelection.isEmpty()#
Return type:

bool

PySide6.QtCore.QItemSelection.isSharedWith(other)#
Parameters:

other

Return type:

bool

PySide6.QtCore.QItemSelection.last()#
Return type:

PySide6.QtCore.QItemSelectionRange

PySide6.QtCore.QItemSelection.last(n)
Parameters:

nqsizetype

PySide6.QtCore.QItemSelection.length()#
Return type:

qsizetype

PySide6.QtCore.QItemSelection.merge(other, command)#
Parameters:

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

Note that only Select , Deselect , and Toggle are supported.

See also

split()

PySide6.QtCore.QItemSelection.mid(pos[, len=-1])#
Parameters:
  • posqsizetype

  • lenqsizetype

PySide6.QtCore.QItemSelection.move(from, to)#
Parameters:
  • fromqsizetype

  • toqsizetype

PySide6.QtCore.QItemSelection.__ne__(arg__1)#
Parameters:

arg__1PySide6.QtCore.QItemSelection

Return type:

bool

PySide6.QtCore.QItemSelection.__add__(arg__1)#
Parameters:

arg__1PySide6.QtCore.QItemSelection

Return type:

PySide6.QtCore.QItemSelection

PySide6.QtCore.QItemSelection.__iadd__(l)#
Parameters:

l

PySide6.QtCore.QItemSelection.__lshift__(l)#
Parameters:

l

PySide6.QtCore.QItemSelection.__eq__(arg__1)#
Parameters:

arg__1PySide6.QtCore.QItemSelection

Return type:

bool

PySide6.QtCore.QItemSelection.operator[](i)
Parameters:

iqsizetype

Return type:

PySide6.QtCore.QItemSelectionRange

PySide6.QtCore.QItemSelection.pop_back()#
PySide6.QtCore.QItemSelection.pop_front()#
PySide6.QtCore.QItemSelection.prepend(arg__1)#
Parameters:

arg__1PySide6.QtCore.QItemSelectionRange

PySide6.QtCore.QItemSelection.push_back(arg__1)#
Parameters:

arg__1PySide6.QtCore.QItemSelectionRange

PySide6.QtCore.QItemSelection.push_front(arg__1)#
Parameters:

arg__1PySide6.QtCore.QItemSelectionRange

PySide6.QtCore.QItemSelection.remove(i[, n=1])#
Parameters:
  • iqsizetype

  • nqsizetype

PySide6.QtCore.QItemSelection.removeAll(arg__1)#
Parameters:

arg__1PySide6.QtCore.QItemSelectionRange

PySide6.QtCore.QItemSelection.removeAt(i)#
Parameters:

iqsizetype

PySide6.QtCore.QItemSelection.removeFirst()#
PySide6.QtCore.QItemSelection.removeLast()#
PySide6.QtCore.QItemSelection.removeOne(arg__1)#
Parameters:

arg__1PySide6.QtCore.QItemSelectionRange

PySide6.QtCore.QItemSelection.reserve(size)#
Parameters:

sizeqsizetype

PySide6.QtCore.QItemSelection.resize(size)#
Parameters:

sizeqsizetype

PySide6.QtCore.QItemSelection.select(topLeft, bottomRight)#
Parameters:

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.

Note

topLeft and bottomRight must have the same parent.

PySide6.QtCore.QItemSelection.shrink_to_fit()#
PySide6.QtCore.QItemSelection.size()#
Return type:

qsizetype

PySide6.QtCore.QItemSelection.sliced(pos)#
Parameters:

posqsizetype

PySide6.QtCore.QItemSelection.sliced(pos, n)
Parameters:
  • posqsizetype

  • nqsizetype

static PySide6.QtCore.QItemSelection.split(range, other, result)#
Parameters:

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.

See also

merge()

PySide6.QtCore.QItemSelection.squeeze()#
PySide6.QtCore.QItemSelection.swap(other)#
Parameters:

other

PySide6.QtCore.QItemSelection.swapItemsAt(i, j)#
Parameters:
  • iqsizetype

  • jqsizetype

PySide6.QtCore.QItemSelection.takeAt(i)#
Parameters:

iqsizetype

Return type:

PySide6.QtCore.QItemSelectionRange

PySide6.QtCore.QItemSelection.toList()#
PySide6.QtCore.QItemSelection.toVector()#
PySide6.QtCore.QItemSelection.value(i)#
Parameters:

iqsizetype

Return type:

PySide6.QtCore.QItemSelectionRange