Skip to content

PythonQt.QtCore.QAbstractListModel

QAbstractListModel

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

QAbstractListModel provides a standard interface for models that represent their data as a simple non-hierarchical sequence of items. It is not used directly, but must be subclassed.

Since the model provides a more specialized interface than QAbstractItemModel, it is not suitable for use with tree views; you will need to subclass QAbstractItemModel if you want to provide a model for that purpose. If you need to use a number of list models to manage data, it may be more appropriate to subclass QAbstractTableModel instead.

Simple models can be created by subclassing this class and implementing the minimum number of required functions. For example, we could implement a simple read-only QStringList-based model that provides a list of strings to a QListView widget. In such a case, we only need to implement the rowCount() function to return the number of items in the list, and the data() function to retrieve items from the list.

Since the model represents a one-dimensional structure, the rowCount() function returns the total number of items in the model. The columnCount() function is implemented for interoperability with all kinds of views, but by default informs views that the model contains only one column.

Subclassing

When subclassing QAbstractListModel, you must provide implementations of the rowCount() and data() functions. Well behaved models also provide a headerData() implementation.

If your model is used within QML and requires roles other than the default ones provided by the roleNames() function, you must override it.

For editable list models, you must also provide an implementation of setData(), and implement the flags() function so that it returns a value containing Qt::ItemIsEditable.

Note that QAbstractListModel provides a default implementation of columnCount() that informs views that there is only a single column of items in this model.

Models that provide interfaces to resizable list-like data structures can provide implementations of insertRows() and removeRows(). When implementing these functions, it is important to call the appropriate functions so that all connected views are aware of any changes:

Note: Some general guidelines for subclassing models are available in the Model Subclassing Reference.

Source: https://doc.qt.io/archives/qt-5.15/qabstractlistmodel.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
CheckIndexOption attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
DoNotUseParent attribute Any (shared captured text)
HorizontalSortHint attribute Any (shared captured text)
IndexIsValid attribute Any (shared captured text)
LayoutChangeHint attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
NoLayoutChangeHint attribute Any (shared captured text)
NoOption attribute Any (shared captured text)
ParentIsInvalid attribute Any (shared captured text)
VerticalSortHint attribute Any (shared captured text)
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
beginInsertColumns function (self, parent: Any, first: Any, last: Any) -> Any X.beginInsertColumns(parent, first, last)
beginInsertRows function (self, parent: Any, first: Any, last: Any) -> Any X.beginInsertRows(parent, first, last)
beginMoveColumns function (self, sourceParent: Any, sourceFirst: Any, sourceLast: Any, destinationParent: Any, destinationColumn: Any) … X.beginMoveColumns(sourceParent, sourceFirst, sourceLast, destinationParent, destinationColumn) -> bool
beginMoveRows function (self, sourceParent: Any, sourceFirst: Any, sourceLast: Any, destinationParent: Any, destinationRow: Any) -> … X.beginMoveRows(sourceParent, sourceFirst, sourceLast, destinationParent, destinationRow) -> bool
beginRemoveColumns function (self, parent: Any, first: Any, last: Any) -> Any X.beginRemoveColumns(parent, first, last)
beginRemoveRows function (self, parent: Any, first: Any, last: Any) -> Any X.beginRemoveRows(parent, first, last)
beginResetModel function (self) -> Any
blockSignals function (self, b: Any) -> bool X.blockSignals(b) -> bool (shared captured text)
buddy function (self, index: Any) -> Any X.buddy(index) -> PythonQt.QtCore.QModelIndex
canDropMimeData function (self, data: Any, action: Any, row: Any, column: Any, parent: Any) -> bool X.canDropMimeData(data, action, row, column, parent) -> bool
canFetchMore function (self, parent: Any) -> bool X.canFetchMore(parent) -> bool
changePersistentIndex function (self, *args: Any, **kwargs: Any) -> Any X.changePersistentIndex(from, to)
changePersistentIndexList function (self, *args: Any, **kwargs: Any) -> Any X.changePersistentIndexList(from, to)
childEvent function (self, event: Any) -> Any (shared captured text)
children function (self) -> tuple X.children() -> tuple (shared captured text)
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
columnCount function (self, parent: Any) -> int X.columnCount(parent) -> int
columnsAboutToBeInserted function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.columnsAboutToBeInserted; argument details are not documented.
columnsAboutToBeMoved function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.columnsAboutToBeMoved; argument details are not documented.
columnsAboutToBeRemoved function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.columnsAboutToBeRemoved; argument details are not documented.
columnsInserted function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.columnsInserted; argument details are not documented.
columnsMoved function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.columnsMoved; argument details are not documented.
columnsRemoved function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.columnsRemoved; argument details are not documented.
connect function (self, signal: Any, receiver: Any, slot: Any, type: Any) -> bool X.connect(signal, receiver, slot, type) -> bool (shared captured text)
createIndex function (self, row: Any, column: Any, id: Any) -> Any X.createIndex(row, column, id) -> PythonQt.QtCore.QModelIndex
customEvent function (self, event: Any) -> Any (shared captured text)
data function (self, index: Any, role: Any) -> Any X.data(index, role) -> object
dataChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.dataChanged; argument details are not documented.
decodeData function (self, row: Any, column: Any, parent: Any, stream: Any) -> bool X.decodeData(row, column, parent, stream) -> bool
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
deleteLater function (self) -> Any (shared captured text)
destroyed function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.destroyed; argument details are not documented.
disconnect function (self, signal: Any, receiver: Any, slot: Any) -> bool X.disconnect(signal, receiver, slot) -> bool (shared captured text)
dropMimeData function (self, data: Any, action: Any, row: int, column: int, parent: Any) -> bool X.dropMimeData(data, action, row, column, parent) -> bool
dumpObjectInfo function (self) -> Any (shared captured text)
dumpObjectTree function (self) -> Any (shared captured text)
dynamicPropertyNames function (self) -> Any (shared captured text)
encodeData function (self, indexes: Any, stream: Any) -> Any X.encodeData(indexes, stream)
endInsertColumns function (self) -> Any
endInsertRows function (self) -> Any
endMoveColumns function (self) -> Any
endMoveRows function (self) -> Any
endRemoveColumns function (self) -> Any
endRemoveRows function (self) -> Any
endResetModel function (self) -> Any
event function (self, event: Any) -> bool X.event(event) -> bool (shared captured text)
eventFilter function (self, watched: Any, event: Any) -> bool X.eventFilter(watched, event) -> bool (shared captured text)
fetchMore function (self, parent: Any) -> Any
findChild function (self, type: Any, name: Any) -> Any X.findChild(type, name) -> PythonQt.private.QObject (shared captured text)
findChildren function (self, type: Any, name: Any) -> tuple X.findChildren(type, name) -> tuple (shared captured text)
flags function (self, index: Any) -> Any Reimplements: [QAbstractItemModel::flags](https://doc.qt.io/archives/qt-5.15/qabstractitemmodel.html#flags)(const QModelIndex \&index) const.
hasChildren function (self, parent: Any) -> bool X.hasChildren(parent) -> bool
hasIndex function (self, row: Any, column: Any, parent: Any) -> bool X.hasIndex(row, column, parent) -> bool
headerData function (self, section: Any, orientation: Any, role: Any) -> Any X.headerData(section, orientation, role) -> object
headerDataChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.headerDataChanged; argument details are not documented.
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
index function (self, row: int, column: int, parent: Any) -> Any X.index(row, column, parent) -> PythonQt.QtCore.QModelIndex
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
insertColumn function (self, column: Any, parent: Any) -> bool X.insertColumn(column, parent) -> bool
insertColumns function (self, column: Any, count: Any, parent: Any) -> bool X.insertColumns(column, count, parent) -> bool
insertRow function (self, row: Any, parent: Any) -> bool X.insertRow(row, parent) -> bool
insertRows function (self, row: Any, count: Any, parent: Any) -> bool X.insertRows(row, count, parent) -> bool
installEventFilter function (self, filterObj: Any) -> Any (shared captured text)
isSignalConnected function (self, signal: Any) -> bool X.isSignalConnected(signal) -> bool (shared captured text)
isWidgetType function (self) -> bool X.isWidgetType() -> bool (shared captured text)
isWindowType function (self) -> bool X.isWindowType() -> bool (shared captured text)
itemData function (self, index: Any) -> dict X.itemData(index) -> dict
killTimer function (self, id: Any) -> Any (shared captured text)
layoutAboutToBeChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.layoutAboutToBeChanged; argument details are not documented.
layoutChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.layoutChanged; argument details are not documented.
match function (self, start: Any, role: Any, value: Any, hits: Any, arg4: flags) -> tuple X.match(start, role, value, hits, flags) -> tuple
metaObject function (self) -> Any X.metaObject() -> PythonQt.QtCore.QMetaObject (shared captured text)
mimeData function (self, indexes: Any) -> Any X.mimeData(indexes) -> PythonQt.QtCore.QMimeData
mimeTypes function (self) -> tuple X.mimeTypes() -> tuple
modelAboutToBeReset function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.modelAboutToBeReset; argument details are not documented.
modelReset function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.modelReset; argument details are not documented.
moveColumn function (self, sourceParent: Any, sourceColumn: Any, destinationParent: Any, destinationChild: Any) -> bool X.moveColumn(sourceParent, sourceColumn, destinationParent, destinationChild) -> bool
moveColumns function (self, sourceParent: Any, sourceColumn: Any, count: Any, destinationParent: Any, destinationChild: Any) -> bo… X.moveColumns(sourceParent, sourceColumn, count, destinationParent, destinationChild) -> bool
moveRow function (self, sourceParent: Any, sourceRow: Any, destinationParent: Any, destinationChild: Any) -> bool X.moveRow(sourceParent, sourceRow, destinationParent, destinationChild) -> bool
moveRows function (self, sourceParent: Any, sourceRow: Any, count: Any, destinationParent: Any, destinationChild: Any) -> bool X.moveRows(sourceParent, sourceRow, count, destinationParent, destinationChild) -> bool
moveToThread function (self, thread: Any) -> Any (shared captured text)
objectName attribute Any (shared captured text)
objectNameChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.objectNameChanged; argument details are not documented.
parent function (self, child: Any) -> Any X.parent(child) -> PythonQt.QtCore.QModelIndex
persistentIndexList function (self) -> tuple X.persistentIndexList() -> tuple
property function (self, name: Any) -> Any X.property(name) -> object (shared captured text)
removeColumn function (self, column: Any, parent: Any) -> bool X.removeColumn(column, parent) -> bool
removeColumns function (self, column: Any, count: Any, parent: Any) -> bool X.removeColumns(column, count, parent) -> bool
removeEventFilter function (self, obj: Any) -> Any (shared captured text)
removeRow function (self, row: Any, parent: Any) -> bool X.removeRow(row, parent) -> bool
removeRows function (self, row: Any, count: Any, parent: Any) -> bool X.removeRows(row, count, parent) -> bool
revert function (self) -> Any
roleNames function (self) -> dict X.roleNames() -> dict
rowCount function (self, parent: Any) -> int X.rowCount(parent) -> int
rowsAboutToBeInserted function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.rowsAboutToBeInserted; argument details are not documented.
rowsAboutToBeMoved function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.rowsAboutToBeMoved; argument details are not documented.
rowsAboutToBeRemoved function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.rowsAboutToBeRemoved; argument details are not documented.
rowsInserted function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.rowsInserted; argument details are not documented.
rowsMoved function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.rowsMoved; argument details are not documented.
rowsRemoved function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.QtCore.QAbstractListModel.rowsRemoved; argument details are not documented.
sender function (self) -> Any X.sender() -> PythonQt.private.QObject (shared captured text)
senderSignalIndex function (self) -> int X.senderSignalIndex() -> int (shared captured text)
setData function (self, index: Any, value: Any, role: Any) -> bool X.setData(index, value, role) -> bool
setHeaderData function (self, section: Any, orientation: Any, value: Any, role: Any) -> bool X.setHeaderData(section, orientation, value, role) -> bool
setItemData function (self, index: Any, roles: Any) -> bool X.setItemData(index, roles) -> bool
setObjectName function (self, name: Any) -> Any (shared captured text)
setParent function (self, parent: Any) -> Any (shared captured text)
setProperty function (self, name: Any, value: Any) -> bool X.setProperty(name, value) -> bool (shared captured text)
sibling function (self, row: int, column: int, idx: Any) -> Any X.sibling(row, column, idx) -> PythonQt.QtCore.QModelIndex
signalsBlocked function (self) -> bool X.signalsBlocked() -> bool (shared captured text)
sort function (self, column: Any, order: Any) -> Any X.sort(column, order)
span function (self, index: Any) -> Any X.span(index) -> PythonQt.QtCore.QSize
startTimer function (self, interval: Any, timerType: Any) -> int X.startTimer(interval, timerType) -> int (shared captured text)
submit function (self) -> bool X.submit() -> bool
supportedDragActions function (self) -> Any
supportedDropActions function (self) -> Any
thread function (self) -> Any (shared captured text)
timerEvent function (self, event: Any) -> Any (shared captured text)
tr function (self, text: Any, ambig: Any, n: Any) -> str X.tr(text, ambig, n) -> str (shared captured text)