PySide6.QtCore.QAbstractItemModel¶
- class QAbstractItemModel¶
- The - QAbstractItemModelclass provides the abstract interface for item model classes. More…- Inherited by: - QFileSystemModel,- QAbstractItemModelReplica,- QPdfBookmarkModel,- QHelpContentModel,- QStandardItemModel,- QConcatenateTablesProxyModel,- QAbstractTableModel,- QSqlQueryModel,- QSqlTableModel,- QSqlRelationalTableModel,- QAbstractProxyModel,- QTransposeProxyModel,- QSortFilterProxyModel,- QIdentityProxyModel,- QAbstractListModel,- QWebEngineHistoryModel,- QPdfSearchModel,- QPdfLinkModel,- QStringListModel,- QHelpIndexModel- Synopsis¶- Methods¶- def - __init__()
- def - beginMoveRows()
- def - checkIndex()
- def - createIndex()
- def - decodeData()
- def - encodeData()
- def - endInsertRows()
- def - endMoveColumns()
- def - endMoveRows()
- def - endRemoveRows()
- def - endResetModel()
- def - hasIndex()
- def - insertColumn()
- def - insertRow()
- def - moveColumn()
- def - moveRow()
- def - removeColumn()
- def - removeRow()
 - Virtual methods¶- def - buddy()
- def - canFetchMore()
- def - clearItemData()
- def - columnCount()
- def - data()
- def - dropMimeData()
- def - fetchMore()
- def - flags()
- def - hasChildren()
- def - headerData()
- def - index()
- def - insertColumns()
- def - insertRows()
- def - itemData()
- def - match()
- def - mimeData()
- def - mimeTypes()
- def - moveColumns()
- def - moveRows()
- def - multiData()
- def - parent()
- def - removeColumns()
- def - removeRows()
- def - revert()
- def - roleNames()
- def - rowCount()
- def - setData()
- def - setHeaderData()
- def - setItemData()
- def - sibling()
- def - sort()
- def - span()
- def - submit()
 - Signals¶
- def - columnsMoved()
- def - columnsRemoved()
- def - dataChanged()
- def - layoutChanged()
- def - modelReset()
- def - rowsInserted()
- def - rowsMoved()
- def - rowsRemoved()
 - 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¶- The - QAbstractItemModelclass defines the standard interface that item models must use to be able to interoperate with other components in the model/view architecture. It is not supposed to be instantiated directly. Instead, you should subclass it to create new models.- The - QAbstractItemModelclass is one of the Model/View Classes and is part of Qt’s model/view framework. It can be used as the underlying data model for the item view elements in QML or the item view classes in the Qt Widgets module.- If you need a model to use with an item view such as QML’s List View element or the C++ widgets QListView or QTableView, you should consider subclassing - QAbstractListModelor- QAbstractTableModelinstead of this class.- The underlying data model is exposed to views and delegates as a hierarchy of tables. If you do not make use of the hierarchy, then the model is a simple table of rows and columns. Each item has a unique index specified by a - QModelIndex.  - Every item of data that can be accessed via a model has an associated model index. You can obtain this model index using the - index()function. Each index may have a- sibling()index; child items have a- parent()index.- Each item has a number of data elements associated with it and they can be retrieved by specifying a role (see - ItemDataRole) to the model’s- data()function. Data for all available roles can be obtained at the same time using the- itemData()function.- Data for each role is set using a particular - ItemDataRole. Data for individual roles are set individually with- setData(), or they can be set for all roles with- setItemData().- Items can be queried with - flags()(see- ItemFlag) to see if they can be selected, dragged, or manipulated in other ways.- If an item has child objects, - hasChildren()returns- truefor the corresponding index.- The model has a - rowCount()and a- columnCount()for each level of the hierarchy. Rows and columns can be inserted and removed with- insertRows(),- insertColumns(),- removeRows(), and- removeColumns().- The model emits signals to indicate changes. For example, - dataChanged()is emitted whenever items of data made available by the model are changed. Changes to the headers supplied by the model cause- headerDataChanged()to be emitted. If the structure of the underlying data changes, the model can emit- layoutChanged()to indicate to any attached views that they should redisplay any items shown, taking the new structure into account.- The items available through the model can be searched for particular data using the - match()function.- To sort the model, you can use - sort().- Subclassing¶- Note - Some general guidelines for subclassing models are available in the Model Subclassing Reference. - When subclassing - QAbstractItemModel, at the very least you must implement- index(),- parent(),- rowCount(),- columnCount(), and- data(). These functions are used in all read-only models, and form the basis of editable models.- You can also reimplement - hasChildren()to provide special behavior for models where the implementation of- rowCount()is expensive. This makes it possible for models to restrict the amount of data requested by views, and can be used as a way to implement lazy population of model data.- To enable editing in your model, you must also implement - setData(), and reimplement- flags()to ensure that- ItemIsEditableis returned. You can also reimplement- headerData()and- setHeaderData()to control the way the headers for your model are presented.- The - dataChanged()and- headerDataChanged()signals must be emitted explicitly when reimplementing the- setData()and- setHeaderData()functions, respectively.- Custom models need to create model indexes for other components to use. To do this, call - createIndex()with suitable row and column numbers for the item, and an identifier for it, either as a pointer or as an integer value. The combination of these values must be unique for each item. Custom models typically use these unique identifiers in other reimplemented functions to retrieve item data and access information about the item’s parents and children. See the Simple Tree Model Example for more information about unique identifiers.- It is not necessary to support every role defined in - ItemDataRole. Depending on the type of data contained within a model, it may only be useful to implement the- data()function to return valid information for some of the more common roles. Most models provide at least a textual representation of item data for the- DisplayRole, and well-behaved models should also provide valid information for the- ToolTipRoleand- WhatsThisRole. Supporting these roles enables models to be used with standard Qt views. However, for some models that handle highly-specialized data, it may be appropriate to provide data only for user-defined roles.- Models that provide interfaces to resizable data structures can provide implementations of - insertRows(),- removeRows(),- insertColumns(),and- removeColumns(). When implementing these functions, it is important to notify any connected views about changes to the model’s dimensions both before and after they occur:- An - insertRows()implementation must call- beginInsertRows()before inserting new rows into the data structure, and- endInsertRows()immediately afterwards.
- An - insertColumns()implementation must call- beginInsertColumns()before inserting new columns into the data structure, and- endInsertColumns()immediately afterwards.
- A - removeRows()implementation must call- beginRemoveRows()before the rows are removed from the data structure, and- endRemoveRows()immediately afterwards.
- A - removeColumns()implementation must call- beginRemoveColumns()before the columns are removed from the data structure, and- endRemoveColumns()immediately afterwards.
 - The private signals that these functions emit give attached components the chance to take action before any data becomes unavailable. The encapsulation of the insert and remove operations with these begin and end functions also enables the model to manage - persistent model indexescorrectly. If you want selections to be handled properly, you must ensure that you call these functions. If you insert or remove an item with children, you do not need to call these functions for the child items. In other words, the parent item will take care of its child items.- To create models that populate incrementally, you can reimplement - fetchMore()and- canFetchMore(). If the reimplementation of- fetchMore()adds rows to the model,- beginInsertRows()and- endInsertRows()must be called.- Thread safety¶- Being a subclass of QObject, - QAbstractItemModelis not- thread-safe. Any- QAbstractItemModelmodel-related API should only be called from the thread the model object lives in. If the- QAbstractItemModelis connected with a view, that means the GUI thread, as that is where the view lives, and it will call into the model from the GUI thread. Using a background thread to populate or modify the contents of a model is possible, but requires care, as the background thread cannot call any model-related API directly. Instead, you should queue the updates and apply them in the main thread. This can be done with queued connections.- See also - QModelIndex- QAbstractItemViewUsing drag and drop with item viewsSimple Tree Model ExampleEditable Tree Model ExampleFetch More Example- class LayoutChangeHint¶
- This enum describes the way the model changes layout. - Constant - Description - QAbstractItemModel.NoLayoutChangeHint - No hint is available. - QAbstractItemModel.VerticalSortHint - Rows are being sorted. - QAbstractItemModel.HorizontalSortHint - Columns are being sorted. - Note that VerticalSortHint and HorizontalSortHint carry the meaning that items are being moved within the same parent, not moved to a different parent in the model, and not filtered out or in. 
 - class CheckIndexOption¶
- (inherits - enum.Flag) This enum can be used to control the checks performed by- checkIndex().- Constant - Description - QAbstractItemModel.CheckIndexOption.NoOption - No check options are specified. - QAbstractItemModel.CheckIndexOption.IndexIsValid - The model index passed to - checkIndex()is checked to be a valid model index.- QAbstractItemModel.CheckIndexOption.DoNotUseParent - Does not perform any check involving the usage of the parent of the index passed to - checkIndex().- QAbstractItemModel.CheckIndexOption.ParentIsInvalid - The parent of the model index passed to - checkIndex()is checked to be an invalid model index. If both this option and DoNotUseParent are specified, then this option is ignored.
 - Constructs an abstract item model with the given - parent.- beginInsertColumns(parent, first, last)¶
- Parameters:
- parent – - QModelIndex
- first – int 
- last – int 
 
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Begins a column insertion operation. - When reimplementing - insertColumns()in a subclass, you must call this function before inserting data into the model’s underlying data store.- The - parentindex corresponds to the parent into which the new columns are inserted;- firstand- lastare the column numbers of the new columns will have after they have been inserted. Inserting columns Inserting columns- Specify the first and last column numbers for the span of columns you want to insert into an item in a model. - For example, as shown in the diagram, we insert three columns before column 4, so - firstis 4 and- lastis 6:- beginInsertColumns(parent, 4, 6) - This inserts the three new columns as columns 4, 5, and 6.  Appending columns Appending columns- To append columns, insert them after the last column. - For example, as shown in the diagram, we append three columns to a collection of six existing columns (ending in column 5), so - firstis 6 and- lastis 8:- beginInsertColumns(parent, 6, 8) - This appends the two new columns as columns 6, 7, and 8. - Note - This function emits the - columnsAboutToBeInserted()signal which connected views (or proxies) must handle before the data is inserted. Otherwise, the views may end up in an invalid state.- See also - beginInsertRows(parent, first, last)¶
- Parameters:
- parent – - QModelIndex
- first – int 
- last – int 
 
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Begins a row insertion operation. - When reimplementing - insertRows()in a subclass, you must call this function before inserting data into the model’s underlying data store.- The - parentindex corresponds to the parent into which the new rows are inserted;- firstand- lastare the row numbers that the new rows will have after they have been inserted. Inserting rows Inserting rows- Specify the first and last row numbers for the span of rows you want to insert into an item in a model. - For example, as shown in the diagram, we insert three rows before row 2, so - firstis 2 and- lastis 4:- beginInsertRows(parent, 2, 4) - This inserts the three new rows as rows 2, 3, and 4.  Appending rows Appending rows- To append rows, insert them after the last row. - For example, as shown in the diagram, we append two rows to a collection of 4 existing rows (ending in row 3), so - firstis 4 and- lastis 5:- beginInsertRows(parent, 4, 5) - This appends the two new rows as rows 4 and 5. - Note - This function emits the - rowsAboutToBeInserted()signal which connected views (or proxies) must handle before the data is inserted. Otherwise, the views may end up in an invalid state.- See also - beginMoveColumns(sourceParent, sourceFirst, sourceLast, destinationParent, destinationColumn)¶
- Parameters:
- sourceParent – - QModelIndex
- sourceFirst – int 
- sourceLast – int 
- destinationParent – - QModelIndex
- destinationColumn – int 
 
- Return type:
- bool 
 
 - Begins a column move operation. - When reimplementing a subclass, this method simplifies moving entities in your model. This method is responsible for moving persistent indexes in the model, which you would otherwise be required to do yourself. Using beginMoveColumns and - endMoveColumnsis an alternative to emitting- layoutAboutToBeChangedand- layoutChangeddirectly along with- changePersistentIndex.- The - sourceParentindex corresponds to the parent from which the columns are moved;- sourceFirstand- sourceLastare the first and last column numbers of the columns to be moved. The- destinationParentindex corresponds to the parent into which those columns are moved. The- destinationChildis the column to which the columns will be moved. That is, the index at column- sourceFirstin- sourceParentwill become column- destinationChildin- destinationParent, followed by all other columns up to- sourceLast.- However, when moving columns down in the same parent ( - sourceParentand- destinationParentare equal), the columns will be placed before the- destinationChildindex. That is, if you wish to move columns 0 and 1 so they will become columns 1 and 2,- destinationChildshould be 3. In this case, the new index for the source column- i(which is between- sourceFirstand- sourceLast) is equal to- (destinationChild-sourceLast-1+i).- Note that if - sourceParentand- destinationParentare the same, you must ensure that the- destinationChildis not within the range of- sourceFirstand- sourceLast+ 1. You must also ensure that you do not attempt to move a column to one of its own children or ancestors. This method returns- falseif either condition is true, in which case you should abort your move operation.- See also - beginMoveRows(sourceParent, sourceFirst, sourceLast, destinationParent, destinationRow)¶
- Parameters:
- sourceParent – - QModelIndex
- sourceFirst – int 
- sourceLast – int 
- destinationParent – - QModelIndex
- destinationRow – int 
 
- Return type:
- bool 
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Begins a row move operation. - When reimplementing a subclass, this method simplifies moving entities in your model. This method is responsible for moving persistent indexes in the model, which you would otherwise be required to do yourself. Using beginMoveRows and - endMoveRowsis an alternative to emitting- layoutAboutToBeChangedand- layoutChangeddirectly along with- changePersistentIndex.- The - sourceParentindex corresponds to the parent from which the rows are moved;- sourceFirstand- sourceLastare the first and last row numbers of the rows to be moved. The- destinationParentindex corresponds to the parent into which those rows are moved. The- destinationChildis the row to which the rows will be moved. That is, the index at row- sourceFirstin- sourceParentwill become row- destinationChildin- destinationParent, followed by all other rows up to- sourceLast.- However, when moving rows down in the same parent ( - sourceParentand- destinationParentare equal), the rows will be placed before the- destinationChildindex. That is, if you wish to move rows 0 and 1 so they will become rows 1 and 2,- destinationChildshould be 3. In this case, the new index for the source row- i(which is between- sourceFirstand- sourceLast) is equal to- (destinationChild-sourceLast-1+i).- Note that if - sourceParentand- destinationParentare the same, you must ensure that the- destinationChildis not within the range of- sourceFirstand- sourceLast+ 1. You must also ensure that you do not attempt to move a row to one of its own children or ancestors. This method returns- falseif either condition is true, in which case you should abort your move operation. Moving rows to another parent Moving rows to another parent- Specify the first and last row numbers for the span of rows in the source parent you want to move in the model. Also specify the row in the destination parent to move the span to. - For example, as shown in the diagram, we move three rows from row 2 to 4 in the source, so - sourceFirstis 2 and- sourceLastis 4. We move those items to above row 2 in the destination, so- destinationChildis 2.- beginMoveRows(sourceParent, 2, 4, destinationParent, 2) - This moves the three rows rows 2, 3, and 4 in the source to become 2, 3 and 4 in the destination. Other affected siblings are displaced accordingly.  Moving rows to append to another parent Moving rows to append to another parent- To append rows to another parent, move them to after the last row. - For example, as shown in the diagram, we move three rows to a collection of 6 existing rows (ending in row 5), so - destinationChildis 6:- beginMoveRows(sourceParent, 2, 4, destinationParent, 6) - This moves the target rows to the end of the target parent as 6, 7 and 8.  Moving rows in the same parent up Moving rows in the same parent up- To move rows within the same parent, specify the row to move them to. - For example, as shown in the diagram, we move one item from row 2 to row 0, so - sourceFirstand- sourceLastare 2 and- destinationChildis 0.- beginMoveRows(parent, 2, 2, parent, 0) - Note that other rows may be displaced accordingly. Note also that when moving items within the same parent you should not attempt invalid or no-op moves. In the above example, item 2 is at row 2 before the move, so it cannot be moved to row 2 (where it is already) or row 3 (no-op as row 3 means above row 3, where it is already)  Moving rows in the same parent down Moving rows in the same parent down- To move rows within the same parent, specify the row to move them to. - For example, as shown in the diagram, we move one item from row 2 to row 4, so - sourceFirstand- sourceLastare 2 and- destinationChildis 4.- beginMoveRows(parent, 2, 2, parent, 4) - Note that other rows may be displaced accordingly. - See also - beginRemoveColumns(parent, first, last)¶
- Parameters:
- parent – - QModelIndex
- first – int 
- last – int 
 
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Begins a column removal operation. - When reimplementing - removeColumns()in a subclass, you must call this function before removing data from the model’s underlying data store.- The - parentindex corresponds to the parent from which the new columns are removed;- firstand- lastare the column numbers of the first and last columns to be removed. Removing columns Removing columns- Specify the first and last column numbers for the span of columns you want to remove from an item in a model. - For example, as shown in the diagram, we remove the three columns from column 4 to column 6, so - firstis 4 and- lastis 6:- beginRemoveColumns(parent, 4, 6) - Note - This function emits the - columnsAboutToBeRemoved()signal which connected views (or proxies) must handle before the data is removed. Otherwise, the views may end up in an invalid state.- See also - beginRemoveRows(parent, first, last)¶
- Parameters:
- parent – - QModelIndex
- first – int 
- last – int 
 
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Begins a row removal operation. - When reimplementing - removeRows()in a subclass, you must call this function before removing data from the model’s underlying data store.- The - parentindex corresponds to the parent from which the new rows are removed;- firstand- lastare the row numbers of the rows to be removed. Removing rows Removing rows- Specify the first and last row numbers for the span of rows you want to remove from an item in a model. - For example, as shown in the diagram, we remove the two rows from row 2 to row 3, so - firstis 2 and- lastis 3:- beginRemoveRows(parent, 2, 3) - Note - This function emits the - rowsAboutToBeRemoved()signal which connected views (or proxies) must handle before the data is removed. Otherwise, the views may end up in an invalid state.- See also - beginResetModel()¶
 - Begins a model reset operation. - A reset operation resets the model to its current state in any attached views. - Note - Any views attached to this model will be reset as well. - When a model is reset it means that any previous data reported from the model is now invalid and has to be queried for again. This also means that the current item and any selected items will become invalid. - When a model radically changes its data it can sometimes be easier to just call this function rather than emit - dataChanged()to inform other components when the underlying data source, or its structure, has changed.- You must call this function before resetting any internal data structures in your model or proxy model. - This function emits the signal - modelAboutToBeReset().- buddy(index)¶
- Parameters:
- index – - QModelIndex
- Return type:
 
 - Returns a model index for the buddy of the item represented by - index. When the user wants to edit an item, the view will call this function to check whether another item in the model should be edited instead. Then, the view will construct a delegate using the model index returned by the buddy item.- The default implementation of this function has each item as its own buddy. - canDropMimeData(data, action, row, column, parent)¶
- Parameters:
- data – - QMimeData
- action – - DropAction
- row – int 
- column – int 
- parent – - QModelIndex
 
- Return type:
- bool 
 
 - Returns - trueif a model can accept a drop of the- data. This default implementation only checks if- datahas at least one format in the list of- mimeTypes()and if- actionis among the model’s- supportedDropActions().- Reimplement this function in your custom model, if you want to test whether the - datacan be dropped at- row,- column,- parentwith- action. If you don’t need that test, it is not necessary to reimplement this function.- See also - dropMimeData()- Using drag and drop with item views- canFetchMore(parent)¶
- Parameters:
- parent – - QModelIndex
- Return type:
- bool 
 
 - Returns - trueif there is more data available for- parent; otherwise returns- false.- The default implementation always returns - false.- If canFetchMore() returns - true, the- fetchMore()function should be called. This is the behavior of QAbstractItemView, for example.- See also - changePersistentIndex(from, to)¶
- Parameters:
- from – - QModelIndex
- to – - QModelIndex
 
 
 - Changes the - QPersistentModelIndexthat is equal to the given- frommodel index to the given- tomodel index.- If no persistent model index equal to the given - frommodel index was found, nothing is changed.- changePersistentIndexList(from, to)¶
- Parameters:
- from – .list of QModelIndex 
- to – .list of QModelIndex 
 
 
 - Changes the { - QPersistentModelIndex}es that are equal to the indexes in the given- frommodel index list to the given- tomodel index list.- If no persistent model indexes equal to the indexes in the given - frommodel index list are found, nothing is changed.- checkIndex(index[, options=QAbstractItemModel.CheckIndexOption.NoOption])¶
- Parameters:
- index – - QModelIndex
- options – Combination of - CheckIndexOption
 
- Return type:
- bool 
 
 - This function checks whether - indexis a legal model index for this model. A legal model index is either an invalid model index, or a valid model index for which all the following holds:- the index’ model is - this;
- the index’ row is greater or equal than zero; 
- the index’ row is less than the row count for the index’ parent; 
- the index’ column is greater or equal than zero; 
- the index’ column is less than the column count for the index’ parent. 
 - The - optionsargument may change some of these checks. If- optionscontains- IndexIsValid, then- indexmust be a valid index; this is useful when reimplementing functions such as- data()or- setData(), which expect valid indexes.- If - optionscontains- DoNotUseParent, then the checks that would call- parent()are omitted; this allows calling this function from a- parent()reimplementation (otherwise, this would result in endless recursion and a crash).- If - optionsdoes not contain- DoNotUseParent, and it contains- ParentIsInvalid, then an additional check is performed: the parent index is checked for not being valid. This is useful when implementing flat models such as lists or tables, where no model index should have a valid parent index.- This function returns true if all the checks succeeded, and false otherwise. This allows to use the function in - Q_ASSERTand similar other debugging mechanisms. If some check failed, a warning message will be printed in the- qt.core.qabstractitemmodel.checkindexlogging category, containing some information that may be useful for debugging the failure.- Note - This function is a debugging helper for implementing your own item models. When developing complex models, as well as when building complicated model hierarchies (e.g. using proxy models), it is useful to call this function in order to catch bugs relative to illegal model indices (as defined above) accidentally passed to some - QAbstractItemModelAPI.- Warning - Note that it’s undefined behavior to pass illegal indices to item models, so applications must refrain from doing so, and not rely on any “defensive” programming that item models could employ to handle illegal indexes gracefully. - See also - clearItemData(index)¶
- Parameters:
- index – - QModelIndex
- Return type:
- bool 
 
 - Removes the data stored in all the roles for the given - index. Returns- trueif successful; otherwise returns- false. The- dataChanged()signal should be emitted if the data was successfully removed. The base class implementation returns- false- See also - abstract columnCount([parent=QModelIndex()])¶
- Parameters:
- parent – - QModelIndex
- Return type:
- int 
 
 - Returns the number of columns for the children of the given - parent.- In most subclasses, the number of columns is independent of the - parent.- For example: - int MyModel::columnCount(const QModelIndex &parent) const { Q_UNUSED(parent); return 3; } - Note - When implementing a table based model, columnCount() should return 0 when the parent is valid. - See also - columnsAboutToBeInserted(parent, first, last)¶
- Parameters:
- parent – - QModelIndex
- first – int 
- last – int 
 
 
 - This signal is emitted just before columns are inserted into the model. The new items will be positioned between - firstand- lastinclusive, under the given- parentitem.- Note - Components connected to this signal use it to adapt to changes in the model’s dimensions. It can only be emitted by the - QAbstractItemModelimplementation, and cannot be explicitly emitted in subclass code.- See also - columnsAboutToBeMoved(sourceParent, sourceStart, sourceEnd, destinationParent, destinationColumn)¶
- Parameters:
- sourceParent – - QModelIndex
- sourceStart – int 
- sourceEnd – int 
- destinationParent – - QModelIndex
- destinationColumn – int 
 
 
 - This signal is emitted just before columns are moved within the model. The items that will be moved are those between - sourceStartand- sourceEndinclusive, under the given- sourceParentitem. They will be moved to- destinationParentstarting at the column- destinationColumn.- Note - Components connected to this signal use it to adapt to changes in the model’s dimensions. It can only be emitted by the - QAbstractItemModelimplementation, and cannot be explicitly emitted in subclass code.- See also - columnsAboutToBeRemoved(parent, first, last)¶
- Parameters:
- parent – - QModelIndex
- first – int 
- last – int 
 
 
 - This signal is emitted just before columns are removed from the model. The items to be removed are those between - firstand- lastinclusive, under the given- parentitem.- Note - Components connected to this signal use it to adapt to changes in the model’s dimensions. It can only be emitted by the - QAbstractItemModelimplementation, and cannot be explicitly emitted in subclass code.- See also - columnsInserted(parent, first, last)¶
- Parameters:
- parent – - QModelIndex
- first – int 
- last – int 
 
 
 - This signal is emitted after columns have been inserted into the model. The new items are those between - firstand- lastinclusive, under the given- parentitem.- Note - Components connected to this signal use it to adapt to changes in the model’s dimensions. It can only be emitted by the - QAbstractItemModelimplementation, and cannot be explicitly emitted in subclass code.- See also - columnsMoved(sourceParent, sourceStart, sourceEnd, destinationParent, destinationColumn)¶
- Parameters:
- sourceParent – - QModelIndex
- sourceStart – int 
- sourceEnd – int 
- destinationParent – - QModelIndex
- destinationColumn – int 
 
 
 - This signal is emitted after columns have been moved within the model. The items between - sourceStartand- sourceEndinclusive, under the given- sourceParentitem have been moved to- destinationParentstarting at the column- destinationColumn.- Note - Components connected to this signal use it to adapt to changes in the model’s dimensions. It can only be emitted by the - QAbstractItemModelimplementation, and cannot be explicitly emitted in subclass code.- See also - columnsRemoved(parent, first, last)¶
- Parameters:
- parent – - QModelIndex
- first – int 
- last – int 
 
 
 - This signal is emitted after columns have been removed from the model. The removed items are those between - firstand- lastinclusive, under the given- parentitem.- Note - Components connected to this signal use it to adapt to changes in the model’s dimensions. It can only be emitted by the - QAbstractItemModelimplementation, and cannot be explicitly emitted in subclass code.- See also - createIndex(row, column, ptr)¶
- Parameters:
- row – int 
- column – int 
- ptr – object 
 
- Return type:
 
 - Creates a model index for the given row and column with the internal pointer ptr. When using a - QSortFilterProxyModel, its indexes have their own internal pointer. It is not advisable to access this internal pointer outside of the model. Use the- data()function instead.- This function provides a consistent interface that model subclasses must use to create model indexes. - Warning - Because of some Qt/Python integration rules, the - ptrargument does not get the reference incremented during the QModelIndex life time. So it is necessary to keep the object used on- ptrargument alive during the whole process. Do not destroy the object if you are not sure about that.- createIndex(row, column[, id=0])
- Parameters:
- row – int 
- column – int 
- id – - quintptr
 
- Return type:
 
 - Creates a model index for the given - rowand- columnwith the internal identifier,- id.- This function provides a consistent interface that model subclasses must use to create model indexes. - See also - abstract data(index[, role=Qt.DisplayRole])¶
- Parameters:
- index – - QModelIndex
- role – int 
 
- Return type:
- object 
 
 - Returns the data stored under the given - rolefor the item referred to by the- index.- Note - If you do not have a value to return, return an invalid (default-constructed) - QVariant.- See also - dataChanged(topLeft, bottomRight[, roles=list()])¶
- Parameters:
- topLeft – - QModelIndex
- bottomRight – - QModelIndex
- roles – .list of int 
 
 
 - This signal is emitted whenever the data in an existing item changes. - If the items are of the same parent, the affected ones are those between - topLeftand- bottomRightinclusive. If the items do not have the same parent, the behavior is undefined.- When reimplementing the - setData()function, this signal must be emitted explicitly.- The optional - rolesargument can be used to specify which data roles have actually been modified. An empty vector in the roles argument means that all roles should be considered modified. The order of elements in the roles argument does not have any relevance.- See also - decodeData(row, column, parent, stream)¶
- Parameters:
- row – int 
- column – int 
- parent – - QModelIndex
- stream – - QDataStream
 
- Return type:
- bool 
 
 - dropMimeData(data, action, row, column, parent)¶
- Parameters:
- data – - QMimeData
- action – - DropAction
- row – int 
- column – int 
- parent – - QModelIndex
 
- Return type:
- bool 
 
 - Handles the - datasupplied by a drag and drop operation that ended with the given- action.- Returns - trueif the data and action were handled by the model; otherwise returns- false.- The specified - row,- columnand- parentindicate the location of an item in the model where the operation ended. It is the responsibility of the model to complete the action at the correct location.- For instance, a drop action on an item in a QTreeView can result in new items either being inserted as children of the item specified by - row,- column, and- parent, or as siblings of the item.- When - rowand- columnare -1 it means that the dropped data should be considered as dropped directly on- parent. Usually this will mean appending the data as child items of- parent. If- rowand- columnare greater than or equal zero, it means that the drop occurred just before the specified- rowand- columnin the specified- parent.- The - mimeTypes()member is called to get the list of acceptable MIME types. This default implementation assumes the default implementation of- mimeTypes(), which returns a single default MIME type. If you reimplement- mimeTypes()in your custom model to return multiple MIME types, you must reimplement this function to make use of them.- See also - supportedDropActions()- canDropMimeData()- Using drag and drop with item views- encodeData(indexes, stream)¶
- Parameters:
- indexes – .list of QModelIndex 
- stream – - QDataStream
 
 
 - endInsertColumns()¶
 - Ends a column insertion operation. - When reimplementing - insertColumns()in a subclass, you must call this function after inserting data into the model’s underlying data store.- See also - endInsertRows()¶
 - Ends a row insertion operation. - When reimplementing - insertRows()in a subclass, you must call this function after inserting data into the model’s underlying data store.- See also - endMoveColumns()¶
 - Ends a column move operation. - When implementing a subclass, you must call this function after moving data within the model’s underlying data store. - See also - endMoveRows()¶
 - Ends a row move operation. - When implementing a subclass, you must call this function after moving data within the model’s underlying data store. - See also - endRemoveColumns()¶
 - Ends a column removal operation. - When reimplementing - removeColumns()in a subclass, you must call this function after removing data from the model’s underlying data store.- See also - endRemoveRows()¶
 - Ends a row removal operation. - When reimplementing - removeRows()in a subclass, you must call this function after removing data from the model’s underlying data store.- See also - endResetModel()¶
 - Completes a model reset operation. - You must call this function after resetting any internal data structure in your model or proxy model. - This function emits the signal - modelReset().- See also - fetchMore(parent)¶
- Parameters:
- parent – - QModelIndex
 
 - Fetches any available data for the items with the parent specified by the - parentindex.- Reimplement this if you are populating your model incrementally. - The default implementation does nothing. - See also - flags(index)¶
- Parameters:
- index – - QModelIndex
- Return type:
- Combination of - ItemFlag
 
 - Returns the item flags for the given - index.- The base class implementation returns a combination of flags that enables the item ( - ItemIsEnabled) and allows it to be selected (- ItemIsSelectable).- See also - ItemFlags- hasChildren([parent=QModelIndex()])¶
- Parameters:
- parent – - QModelIndex
- Return type:
- bool 
 
 - Returns - trueif- parenthas any children; otherwise returns- false.- Use - rowCount()on the parent to find out the number of children.- Note that it is undefined behavior to report that a particular index hasChildren with this method if the same index has the flag - ItemNeverHasChildrenset.- hasIndex(row, column[, parent=QModelIndex()])¶
- Parameters:
- row – int 
- column – int 
- parent – - QModelIndex
 
- Return type:
- bool 
 
 - Returns - trueif the model returns a valid- QModelIndexfor- rowand- columnwith- parent, otherwise returns- false.- headerData(section, orientation[, role=Qt.DisplayRole])¶
- Parameters:
- section – int 
- orientation – - Orientation
- role – int 
 
- Return type:
- object 
 
 - Returns the data for the given - roleand- sectionin the header with the specified- orientation.- For horizontal headers, the section number corresponds to the column number. Similarly, for vertical headers, the section number corresponds to the row number. - See also - headerDataChanged(orientation, first, last)¶
- Parameters:
- orientation – - Orientation
- first – int 
- last – int 
 
 
 - This signal is emitted whenever a header is changed. The - orientationindicates whether the horizontal or vertical header has changed. The sections in the header from the- firstto the- lastneed to be updated.- When reimplementing the - setHeaderData()function, this signal must be emitted explicitly.- If you are changing the number of columns or rows you do not need to emit this signal, but use the begin/end functions (refer to the section on subclassing in the - QAbstractItemModelclass description for details).- See also - abstract index(row, column[, parent=QModelIndex()])¶
- Parameters:
- row – int 
- column – int 
- parent – - QModelIndex
 
- Return type:
 
 - Returns the index of the item in the model specified by the given - row,- columnand- parentindex.- When reimplementing this function in a subclass, call - createIndex()to generate model indexes that other components can use to refer to items in your model.- See also - insertColumn(column[, parent=QModelIndex()])¶
- Parameters:
- column – int 
- parent – - QModelIndex
 
- Return type:
- bool 
 
 - Inserts a single column before the given - columnin the child items of the- parentspecified.- Returns - trueif the column is inserted; otherwise returns- false.- See also - insertColumns(column, count[, parent=QModelIndex()])¶
- Parameters:
- column – int 
- count – int 
- parent – - QModelIndex
 
- Return type:
- bool 
 
 - On models that support this, inserts - countnew columns into the model before the given- column. The items in each new column will be children of the item represented by the- parentmodel index.- If - columnis 0, the columns are prepended to any existing columns.- If - columnis- columnCount(), the columns are appended to any existing columns.- If - parenthas no children, a single row with- countcolumns is inserted.- Returns - trueif the columns were successfully inserted; otherwise returns- false.- The base class implementation does nothing and returns - false.- If you implement your own model, you can reimplement this function if you want to support insertions. Alternatively, you can provide your own API for altering the data. - insertRow(row[, parent=QModelIndex()])¶
- Parameters:
- row – int 
- parent – - QModelIndex
 
- Return type:
- bool 
 
 - Inserts a single row before the given - rowin the child items of the- parentspecified.- Note - This function calls the virtual method - insertRows.- Returns - trueif the row is inserted; otherwise returns- false.- See also - insertRows(row, count[, parent=QModelIndex()])¶
- Parameters:
- row – int 
- count – int 
- parent – - QModelIndex
 
- Return type:
- bool 
 
 - Note - The base class implementation of this function does nothing and returns - false.- On models that support this, inserts - countrows into the model before the given- row. Items in the new row will be children of the item represented by the- parentmodel index.- If - rowis 0, the rows are prepended to any existing rows in the parent.- If - rowis- rowCount(), the rows are appended to any existing rows in the parent.- If - parenthas no children, a single column with- countrows is inserted.- Returns - trueif the rows were successfully inserted; otherwise returns- false.- If you implement your own model, you can reimplement this function if you want to support insertions. Alternatively, you can provide your own API for altering the data. In either case, you will need to call - beginInsertRows()and- endInsertRows()to notify other components that the model has changed.- itemData(index)¶
- Parameters:
- index – - QModelIndex
- Return type:
- Dictionary with keys of type .int and values of type QVariant. 
 
 - Returns a map with values for all predefined roles in the model for the item at the given - index.- Reimplement this function if you want to extend the default behavior of this function to include custom roles in the map. - See also - layoutAboutToBeChanged([parents=list()[, hint=QAbstractItemModel.NoLayoutChangeHint]])¶
- Parameters:
- parents – .list of QPersistentModelIndex 
- hint – - LayoutChangeHint
 
 
 - This signal is emitted just before the layout of a model is changed. Components connected to this signal use it to adapt to changes in the model’s layout. - Subclasses should update any persistent model indexes after emitting layoutAboutToBeChanged(). - The optional - parentsparameter is used to give a more specific notification about what parts of the layout of the model are changing. An empty list indicates a change to the layout of the entire model. The order of elements in the- parentslist is not significant. The optional- hintparameter is used to give a hint about what is happening while the model is relayouting.- See also - layoutChanged([parents=list()[, hint=QAbstractItemModel.NoLayoutChangeHint]])¶
- Parameters:
- parents – .list of QPersistentModelIndex 
- hint – - LayoutChangeHint
 
 
 - This signal is emitted whenever the layout of items exposed by the model has changed; for example, when the model has been sorted. When this signal is received by a view, it should update the layout of items to reflect this change. - When subclassing - QAbstractItemModelor- QAbstractProxyModel, ensure that you emit- layoutAboutToBeChanged()before changing the order of items or altering the structure of the data you expose to views, and emit layoutChanged() after changing the layout.- The optional - parentsparameter is used to give a more specific notification about what parts of the layout of the model are changing. An empty list indicates a change to the layout of the entire model. The order of elements in the- parentslist is not significant. The optional- hintparameter is used to give a hint about what is happening while the model is relayouting.- Subclasses should update any persistent model indexes before emitting layoutChanged(). In other words, when the structure changes: 
- Remember the - QModelIndexthat will change
- Update your internal data 
- emit layoutChanged 
 - match(start, role, value[, hits=1[, flags=Qt.MatchFlags(Qt.MatchStartsWith|Qt.MatchWrap)]])¶
- Parameters:
- start – - QModelIndex
- role – int 
- value – object 
- hits – int 
- flags – Combination of - MatchFlag
 
- Return type:
- .list of QModelIndex 
 
 - Returns a list of indexes for the items in the column of the - startindex where data stored under the given- rolematches the specified- value. The way the search is performed is defined by the- flagsgiven. The list that is returned may be empty. Note also that the order of results in the list may not correspond to the order in the model, if for example a proxy model is used. The order of the results cannot be relied upon.- The search begins from the - startindex, and continues until the number of matching data items equals- hits, the search reaches the last row, or the search reaches- startagain - depending on whether- MatchWrapis specified in- flags. If you want to search for all matching items, use- hits= -1.- By default, this function will perform a wrapping, string-based comparison on all items, searching for items that begin with the search term specified by - value.- Note - The default implementation of this function only searches columns. Reimplement this function to include a different search behavior. - Returns an object that contains serialized items of data corresponding to the list of - indexesspecified. The format used to describe the encoded data is obtained from the- mimeTypes()function. This default implementation uses the default MIME type returned by the default implementation of- mimeTypes(). If you reimplement- mimeTypes()in your custom model to return more MIME types, reimplement this function to make use of them.- If the list of - indexesis empty, or there are no supported MIME types,- Noneis returned rather than a serialized empty list.- See also - mimeTypes()¶
- Return type:
- list of strings 
 
 - Returns the list of allowed MIME types. By default, the built-in models and views use an internal MIME type: - application/x-qabstractitemmodeldatalist.- When implementing drag and drop support in a custom model, if you will return data in formats other than the default internal MIME type, reimplement this function to return your list of MIME types. - If you reimplement this function in your custom model, you must also reimplement the member functions that call it: - mimeData()and- dropMimeData().- See also - modelAboutToBeReset()¶
 - This signal is emitted when - beginResetModel()is called, before the model’s internal state (e.g. persistent model indexes) has been invalidated.- See also - modelReset()¶
 - This signal is emitted when - endResetModel()is called, after the model’s internal state (e.g. persistent model indexes) has been invalidated.- Note that if a model is reset it should be considered that all information previously retrieved from it is invalid. This includes but is not limited to the - rowCount()and- columnCount(),- flags(), data retrieved through- data(), and- roleNames().- See also - moveColumn(sourceParent, sourceColumn, destinationParent, destinationChild)¶
- Parameters:
- sourceParent – - QModelIndex
- sourceColumn – int 
- destinationParent – - QModelIndex
- destinationChild – int 
 
- Return type:
- bool 
 
 - On models that support this, moves - sourceColumnfrom- sourceParentto- destinationChildunder- destinationParent.- Returns - trueif the columns were successfully moved; otherwise returns- false.- See also - moveColumns(sourceParent, sourceColumn, count, destinationParent, destinationChild)¶
- Parameters:
- sourceParent – - QModelIndex
- sourceColumn – int 
- count – int 
- destinationParent – - QModelIndex
- destinationChild – int 
 
- Return type:
- bool 
 
 - On models that support this, moves - countcolumns starting with the given- sourceColumnunder parent- sourceParentto column- destinationChildunder parent- destinationParent.- Returns - trueif the columns were successfully moved; otherwise returns- false.- The base class implementation does nothing and returns - false.- If you implement your own model, you can reimplement this function if you want to support moving. Alternatively, you can provide your own API for altering the data. - See also - moveRow(sourceParent, sourceRow, destinationParent, destinationChild)¶
- Parameters:
- sourceParent – - QModelIndex
- sourceRow – int 
- destinationParent – - QModelIndex
- destinationChild – int 
 
- Return type:
- bool 
 
 - On models that support this, moves - sourceRowfrom- sourceParentto- destinationChildunder- destinationParent.- Returns - trueif the rows were successfully moved; otherwise returns- false.- See also - moveRows(sourceParent, sourceRow, count, destinationParent, destinationChild)¶
- Parameters:
- sourceParent – - QModelIndex
- sourceRow – int 
- count – int 
- destinationParent – - QModelIndex
- destinationChild – int 
 
- Return type:
- bool 
 
 - On models that support this, moves - countrows starting with the given- sourceRowunder parent- sourceParentto row- destinationChildunder parent- destinationParent.- Returns - trueif the rows were successfully moved; otherwise returns- false.- The base class implementation does nothing and returns - false.- If you implement your own model, you can reimplement this function if you want to support moving. Alternatively, you can provide your own API for altering the data. - See also - multiData(index, roleDataSpan)¶
- Parameters:
- index – - QModelIndex
- roleDataSpan – - QModelRoleDataSpan
 
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Fills the - roleDataSpanwith the requested data for the given- index.- The default implementation will call simply - data()for each role in the span. A subclass can reimplement this function to provide data to views more efficiently:- def multiData(self, index, roleDataSpan): for roleData in roleDataSpan: role = roleData.role() # ... obtain the data for index and role ... roleData.setData(result) - In the snippet above, - indexis the same for the entire call. This means that accessing to the necessary data structures in order to retrieve the information for- indexcan be done only once (hoisting the relevant code out of the loop).- The usage of - setData(), or similarly- setValue(), is encouraged over constructing a- QVariantseparately and using a plain assignment operator; this is because the former allow to re-use the memory already allocated for the- QVariantobject stored inside a- QModelRoleData, while the latter always allocates the new variant and then destroys the old one.- Note that views may call multiData() with spans that have been used in previous calls, and therefore may already contain some data. Therefore, it is imperative that if the model cannot return the data for a given role, then it must clear the data in the corresponding - QModelRoleDataobject. This can be done by calling- clearData(), or similarly by setting a default constructed- QVariant, and so on. Failure to clear the data will result in the view believing that the “old” data is meant to be used for the corresponding role.- Finally, in order to avoid code duplication, a subclass may also decide to reimplement - data()in terms of multiData(), by supplying a span of just one element:- def data(self, QModelIndex index, int role): roleData = QModelRoleData(role) multiData(index, roleData) return roleData.data() - Note - Models are not allowed to modify the roles in the span, or to rearrange the span elements. Doing so results in undefined behavior. - Note - It is illegal to pass an invalid model index to this function. - See also - abstract parent(child)¶
- Parameters:
- child – - QModelIndex
- Return type:
 
 - Returns the parent of the model item with the given - index. If the item has no parent, an invalid- QModelIndexis returned.- A common convention used in models that expose tree data structures is that only items in the first column have children. For that case, when reimplementing this function in a subclass the column of the returned - QModelIndexwould be 0.- When reimplementing this function in a subclass, be careful to avoid calling - QModelIndexmember functions, such as- parent(), since indexes belonging to your model will simply call your implementation, leading to infinite recursion.- See also - persistentIndexList()¶
- Return type:
- .list of QModelIndex 
 
 - Returns the list of indexes stored as persistent indexes in the model. - removeColumn(column[, parent=QModelIndex()])¶
- Parameters:
- column – int 
- parent – - QModelIndex
 
- Return type:
- bool 
 
 - Removes the given - columnfrom the child items of the- parentspecified.- Returns - trueif the column is removed; otherwise returns- false.- See also - removeColumns(column, count[, parent=QModelIndex()])¶
- Parameters:
- column – int 
- count – int 
- parent – - QModelIndex
 
- Return type:
- bool 
 
 - On models that support this, removes - countcolumns starting with the given- columnunder parent- parentfrom the model.- Returns - trueif the columns were successfully removed; otherwise returns- false.- The base class implementation does nothing and returns - false.- If you implement your own model, you can reimplement this function if you want to support removing. Alternatively, you can provide your own API for altering the data. - removeRow(row[, parent=QModelIndex()])¶
- Parameters:
- row – int 
- parent – - QModelIndex
 
- Return type:
- bool 
 
 - Removes the given - rowfrom the child items of the- parentspecified.- Returns - trueif the row is removed; otherwise returns- false.- This is a convenience function that calls - removeRows(). The- QAbstractItemModelimplementation of- removeRows()does nothing.- See also - removeRows(row, count[, parent=QModelIndex()])¶
- Parameters:
- row – int 
- count – int 
- parent – - QModelIndex
 
- Return type:
- bool 
 
 - On models that support this, removes - countrows starting with the given- rowunder parent- parentfrom the model.- Returns - trueif the rows were successfully removed; otherwise returns- false.- The base class implementation does nothing and returns - false.- If you implement your own model, you can reimplement this function if you want to support removing. Alternatively, you can provide your own API for altering the data. - resetInternalData()¶
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - This slot is called just after the internal data of a model is cleared while it is being reset. - This slot is provided the convenience of subclasses of concrete proxy models, such as subclasses of - QSortFilterProxyModelwhich maintain extra data.- class CustomDataProxy(QSortFilterProxyModel): Q_OBJECT # public CustomDataProxy(QObject parent) super().__init__(parent) ... QVariant data(QModelIndex index, int role) override if role != Qt.BackgroundRole: return QSortFilterProxyModel.data(index, role) if m_customData.contains(index.row()): return m_customData.value(index.row()) return QSortFilterProxyModel.data(index, role) # private slots def resetInternalData(): m_customData.clear() # private QVariant> = QHash<int,() - revert()¶
 - Lets the model know that it should discard cached information. This function is typically used for row editing. - See also - roleNames()¶
- Return type:
- Dictionary with keys of type .int and values of type QByteArray. 
 
 - Returns the model’s role names. - The default role names set by Qt are: - Qt Role - QML Role Name - display - decoration - edit - toolTip - statusTip - whatsThis - abstract rowCount([parent=QModelIndex()])¶
- Parameters:
- parent – - QModelIndex
- Return type:
- int 
 
 - Returns the number of rows under the given - parent. When the parent is valid it means that rowCount is returning the number of children of parent.- Note - When implementing a table based model, rowCount() should return 0 when the parent is valid. - See also - rowsAboutToBeInserted(parent, first, last)¶
- Parameters:
- parent – - QModelIndex
- first – int 
- last – int 
 
 
 - This signal is emitted just before rows are inserted into the model. The new items will be positioned between - startand- endinclusive, under the given- parentitem.- Note - Components connected to this signal use it to adapt to changes in the model’s dimensions. It can only be emitted by the - QAbstractItemModelimplementation, and cannot be explicitly emitted in subclass code.- See also - rowsAboutToBeMoved(sourceParent, sourceStart, sourceEnd, destinationParent, destinationRow)¶
- Parameters:
- sourceParent – - QModelIndex
- sourceStart – int 
- sourceEnd – int 
- destinationParent – - QModelIndex
- destinationRow – int 
 
 
 - This signal is emitted just before rows are moved within the model. The items that will be moved are those between - sourceStartand- sourceEndinclusive, under the given- sourceParentitem. They will be moved to- destinationParentstarting at the row- destinationRow.- Note - Components connected to this signal use it to adapt to changes in the model’s dimensions. It can only be emitted by the - QAbstractItemModelimplementation, and cannot be explicitly emitted in subclass code.- See also - rowsAboutToBeRemoved(parent, first, last)¶
- Parameters:
- parent – - QModelIndex
- first – int 
- last – int 
 
 
 - This signal is emitted just before rows are removed from the model. The items that will be removed are those between - firstand- lastinclusive, under the given- parentitem.- Note - Components connected to this signal use it to adapt to changes in the model’s dimensions. It can only be emitted by the - QAbstractItemModelimplementation, and cannot be explicitly emitted in subclass code.- See also - rowsInserted(parent, first, last)¶
- Parameters:
- parent – - QModelIndex
- first – int 
- last – int 
 
 
 - This signal is emitted after rows have been inserted into the model. The new items are those between - firstand- lastinclusive, under the given- parentitem.- Note - Components connected to this signal use it to adapt to changes in the model’s dimensions. It can only be emitted by the - QAbstractItemModelimplementation, and cannot be explicitly emitted in subclass code.- See also - rowsMoved(sourceParent, sourceStart, sourceEnd, destinationParent, destinationRow)¶
- Parameters:
- sourceParent – - QModelIndex
- sourceStart – int 
- sourceEnd – int 
- destinationParent – - QModelIndex
- destinationRow – int 
 
 
 - This signal is emitted after rows have been moved within the model. The items between - sourceStartand- sourceEndinclusive, under the given- sourceParentitem have been moved to- destinationParentstarting at the row- destinationRow.- Note - Components connected to this signal use it to adapt to changes in the model’s dimensions. It can only be emitted by the - QAbstractItemModelimplementation, and cannot be explicitly emitted in subclass code.- See also - rowsRemoved(parent, first, last)¶
- Parameters:
- parent – - QModelIndex
- first – int 
- last – int 
 
 
 - This signal is emitted after rows have been removed from the model. The removed items are those between - firstand- lastinclusive, under the given- parentitem.- Note - Components connected to this signal use it to adapt to changes in the model’s dimensions. It can only be emitted by the - QAbstractItemModelimplementation, and cannot be explicitly emitted in subclass code.- See also - setData(index, value[, role=Qt.EditRole])¶
- Parameters:
- index – - QModelIndex
- value – object 
- role – int 
 
- Return type:
- bool 
 
 - Sets the - roledata for the item at- indexto- value.- Returns - trueif successful; otherwise returns- false.- The - dataChanged()signal should be emitted if the data was successfully set.- The base class implementation returns - false. This function and- data()must be reimplemented for editable models.- See also - setHeaderData(section, orientation, value[, role=Qt.EditRole])¶
- Parameters:
- section – int 
- orientation – - Orientation
- value – object 
- role – int 
 
- Return type:
- bool 
 
 - Sets the data for the given - roleand- sectionin the header with the specified- orientationto the- valuesupplied.- Returns - trueif the header’s data was updated; otherwise returns- false.- When reimplementing this function, the - headerDataChanged()signal must be emitted explicitly.- See also - setItemData(index, roles)¶
- Parameters:
- index – - QModelIndex
- roles – Dictionary with keys of type .int and values of type QVariant. 
 
- Return type:
- bool 
 
 - Sets the role data for the item at - indexto the associated value in- roles, for every- ItemDataRole.- Returns - trueif successful; otherwise returns- false.- Roles that are not in - roleswill not be modified.- See also - sibling(row, column, idx)¶
- Parameters:
- row – int 
- column – int 
- idx – - QModelIndex
 
- Return type:
 
 - Returns the sibling at - rowand- columnfor the item at- index, or an invalid- QModelIndexif there is no sibling at that location.- sibling() is just a convenience function that finds the item’s parent, and uses it to retrieve the index of the child item in the specified - rowand- column.- This method can optionally be overridden for implementation-specific optimization. - Sorts the model by - columnin the given- order.- The base class implementation does nothing. - span(index)¶
- Parameters:
- index – - QModelIndex
- Return type:
 
 - Returns the row and column span of the item represented by - index.- Note - Currently, span is not used. - submit()¶
- Return type:
- bool 
 
 - Lets the model know that it should submit cached information to permanent storage. This function is typically used for row editing. - Returns - trueif there is no error; otherwise returns- false.- See also - supportedDragActions()¶
- Return type:
- Combination of - DropAction
 
 - Returns the actions supported by the data in this model. - The default implementation returns - supportedDropActions(). Reimplement this function if you wish to support additional actions.- supportedDragActions() is used by QAbstractItemView::startDrag() as the default values when a drag occurs. - See also - DropActions- Using drag and drop with item views- supportedDropActions()¶
- Return type:
- Combination of - DropAction
 
 - Returns the drop actions supported by this model. - The default implementation returns - CopyAction. Reimplement this function if you wish to support additional actions. You must also reimplement the- dropMimeData()function to handle the additional operations.- See also - dropMimeData()- DropActions- Using drag and drop with item views