Subgroup: Attribute
Class: QgsAttributeTableModel¶
-
class
qgis.gui.
QgsAttributeTableModel
¶ Bases:
PyQt5.QtCore.QAbstractTableModel
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a QAbstractItemView.
Is able to generate editor widgets for its QModelIndexes as well. Is mostly referred to as “master model” within this doc and the source.
see <a href=”http://doc.qt.digia.com/qt/model-view-programming.html”>Qt Model View Programming</a>
Methods
beginInsertColumns
beginInsertRows
beginMoveColumns
beginMoveRows
beginRemoveColumns
beginRemoveRows
beginResetModel
blockSignals
buddy
canDropMimeData
canFetchMore
changePersistentIndex
changePersistentIndexList
childEvent
children
columnCount
Returns the number of columns connectNotify
createIndex
customEvent
data
Returns data on the given index decodeData
deleteLater
disconnect
disconnectNotify
dropMimeData
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
editorContext
Returns the context in which this table is shown. encodeData
endInsertColumns
endInsertRows
endMoveColumns
endMoveRows
endRemoveColumns
endRemoveRows
endResetModel
event
eventFilter
executeAction
Execute an action executeMapLayerAction
Execute a QgsMapLayerAction
extraColumns
Empty extra columns to announce from this model. feature
Return the feature attributes at given model index fetchMore
fieldCol
get column from field index fieldConditionalStyleChanged
Handles updating the model when the conditional style for a field changes. fieldIdx
get field index from column findChild
findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject findChildren
findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] flags
Returns item flags for the index hasChildren
hasIndex
headerData
Returns header data idToIndex
idToIndexList
idToRow
Maps feature id to table row index
inherits
insertColumn
insertColumns
insertRow
insertRows
installEventFilter
isSignalConnected
isWidgetType
isWindowType
itemData
killTimer
layer
Returns the layer this model uses as backend. layerCache
Returns the layer cache this model uses as backend. loadLayer
Loads the layer into the model match
metaObject
mimeData
mimeTypes
moveColumn
moveColumns
moveRow
moveRows
moveToThread
objectName
parent
persistentIndexList
prefetchColumnData
Caches the entire data for one column. prefetchSortData
Prefetches the entire data for one expression. property
pyqtConfigure
Each keyword argument is either the name of a Qt property or a Qt signal. receivers
reload
Reloads the model data between indices removeColumn
removeColumns
removeEventFilter
removeRow
removeRows
Remove rows request
resetInternalData
resetModel
Resets the model revert
roleNames
rowCount
Returns the number of rows rowToId
Maps row to feature id sender
senderSignalIndex
setData
Updates data on given index setEditorContext
Sets the context in which this table is shown. setExtraColumns
Empty extra columns to announce from this model. setHeaderData
setItemData
setObjectName
setParent
setProperty
setRequest
Set a request that will be used to fill this attribute table model. sibling
signalsBlocked
sort
sortCacheExpression
The expression which was used to fill the sorting cache span
startTimer
submit
supportedDragActions
supportedDropActions
swapRows
Swaps two rows thread
timerEvent
tr
Attributes
FeatureIdRole
FieldIndexRole
HorizontalSortHint
NoLayoutChangeHint
SortRole
UserRole
VerticalSortHint
columnsAboutToBeInserted
columnsAboutToBeInserted(self, QModelIndex, int, int) [signal] columnsAboutToBeMoved
columnsAboutToBeMoved(self, QModelIndex, int, int, QModelIndex, int) [signal] columnsAboutToBeRemoved
columnsAboutToBeRemoved(self, QModelIndex, int, int) [signal] columnsInserted
columnsInserted(self, QModelIndex, int, int) [signal] columnsMoved
columnsMoved(self, QModelIndex, int, int, QModelIndex, int) [signal] columnsRemoved
columnsRemoved(self, QModelIndex, int, int) [signal] dataChanged
dataChanged(self, QModelIndex, QModelIndex, Iterable[int] = []) [signal] destroyed
destroyed(self, QObject = None) [signal] finished
finished(self) [signal] layoutAboutToBeChanged
layoutAboutToBeChanged(self, object = QList<QPersistentModelIndex>(), QAbstractItemModel.LayoutChangeHint = QAbstractItemModel.NoLayoutChangeHint) [signal] layoutChanged
layoutChanged(self, Iterable[QPersistentModelIndex] = [], QAbstractItemModel.LayoutChangeHint = QAbstractItemModel.NoLayoutChangeHint) [signal] modelAboutToBeReset
modelAboutToBeReset(self) [signal] modelChanged
Model has been changed [signal] modelReset
modelReset(self) [signal] objectNameChanged
objectNameChanged(self, str) [signal] rowsAboutToBeInserted
rowsAboutToBeInserted(self, QModelIndex, int, int) [signal] rowsAboutToBeMoved
rowsAboutToBeMoved(self, QModelIndex, int, int, QModelIndex, int) [signal] rowsAboutToBeRemoved
rowsAboutToBeRemoved(self, QModelIndex, int, int) [signal] rowsInserted
rowsInserted(self, QModelIndex, int, int) [signal] rowsMoved
rowsMoved(self, QModelIndex, int, int, QModelIndex, int) [signal] rowsRemoved
rowsRemoved(self, QModelIndex, int, int) [signal] staticMetaObject
-
FeatureIdRole
= 258¶
-
FieldIndexRole
= 259¶
-
class
Role
¶ Bases:
int
-
SortRole
= 257¶
-
UserRole
= 260¶
-
beginInsertColumns
()¶
-
beginInsertRows
()¶
-
beginMoveColumns
()¶
-
beginMoveRows
()¶
-
beginRemoveColumns
()¶
-
beginRemoveRows
()¶
-
beginResetModel
()¶
-
changePersistentIndex
()¶
-
changePersistentIndexList
()¶
-
childEvent
()¶
-
columnCount
(self, parent: QModelIndex = QModelIndex()) → int¶ Returns the number of columns
Parameters: parent – parent index
-
connectNotify
()¶
-
createIndex
()¶
-
customEvent
()¶
-
data
(self, index: QModelIndex, role: int) → Any¶ Returns data on the given index
Parameters: - index – model index
- role – data role
-
decodeData
()¶
-
disconnectNotify
()¶
-
editorContext
(self) → QgsAttributeEditorContext¶ Returns the context in which this table is shown. Will be forwarded to any editor widget created when editing data on this model.
Returns: The context
-
encodeData
()¶
-
endInsertColumns
()¶
-
endInsertRows
()¶
-
endMoveColumns
()¶
-
endMoveRows
()¶
-
endRemoveColumns
()¶
-
endRemoveRows
()¶
-
endResetModel
()¶
-
executeAction
(self, action: QUuid, idx: QModelIndex)¶ Execute an action
-
executeMapLayerAction
(self, action: QgsMapLayerAction, idx: QModelIndex)¶ Execute a
QgsMapLayerAction
-
extraColumns
(self) → int¶ Empty extra columns to announce from this model. Any extra columns need to be implemented by proxy models in front of this model.
-
feature
(self, idx: QModelIndex) → QgsFeature¶ Return the feature attributes at given model index
Returns: feature attributes at given model index
-
fieldCol
(self, idx: int) → int¶ get column from field index
-
fieldConditionalStyleChanged
(self, fieldName: str)¶ Handles updating the model when the conditional style for a field changes.
Parameters: fieldName – name of field whose conditional style has changed New in version 2.12.
-
fieldIdx
(self, col: int) → int¶ get field index from column
-
finished
¶ finished(self) [signal]
-
flags
(self, index: QModelIndex) → Qt.ItemFlags¶ Returns item flags for the index
Parameters: index – model index
-
headerData
(self, section: int, orientation: Qt.Orientation, role: int = Qt.DisplayRole) → Any¶ Returns header data
Parameters: - section – required section
- orientation – horizontal or vertical orientation
- role – data role
-
idToIndex
(self, id: int) → QModelIndex¶
-
idToIndexList
(self, id: int) → object¶
-
idToRow
(self, id: int) → int¶ Maps feature id to table row
Parameters: id – feature id
-
isSignalConnected
()¶
-
layer
(self) → QgsVectorLayer¶ Returns the layer this model uses as backend. Retrieved from the layer cache.
-
layerCache
(self) → QgsVectorLayerCache¶ Returns the layer cache this model uses as backend.
-
loadLayer
(self)¶ Loads the layer into the model Preferably to be called, before using this model as source for any other proxy model
-
modelChanged
¶ Model has been changed [signal]
-
persistentIndexList
()¶
-
prefetchColumnData
(self, column: int)¶ Caches the entire data for one column. This should be called prior to sorting, so the data does not have to be fetched for every single comparison. Specify -1 as column to invalidate the cache
Parameters: column – The column index of the field to catch
-
prefetchSortData
(self, expression: str)¶ Prefetches the entire data for one expression. Based on this cached information the sorting can later be done in a performant way.
Parameters: expression – The expression to cache
-
receivers
()¶
-
reload
(self, index1: QModelIndex, index2: QModelIndex)¶ Reloads the model data between indices
Parameters: - index1 – start index
- index2 – end index
-
removeRows
(self, row: int, count: int, parent: QModelIndex = QModelIndex()) → bool¶ Remove rows
-
request
(self) → QgsFeatureRequest¶
-
resetInternalData
()¶
-
resetModel
(self)¶ Resets the model
Alias to loadLayer()
-
rowCount
(self, parent: QModelIndex = QModelIndex()) → int¶ Returns the number of rows
Parameters: parent – parent index
-
rowToId
(self, row: int) → int¶ Maps row to feature id
Parameters: row – row number
-
sender
()¶
-
senderSignalIndex
()¶
-
setData
(self, index: QModelIndex, value: Any, role: int = Qt.EditRole) → bool¶ Updates data on given index
Parameters: - index – model index
- value – new data value
- role – data role
-
setEditorContext
(self, context: QgsAttributeEditorContext)¶ Sets the context in which this table is shown. Will be forwarded to any editor widget created when editing data on this model.
Parameters: context – The context
-
setExtraColumns
(self, extraColumns: int)¶ Empty extra columns to announce from this model. Any extra columns need to be implemented by proxy models in front of this model.
-
setRequest
(self, request: QgsFeatureRequest)¶ Set a request that will be used to fill this attribute table model. In contrast to a filter, the request will constrain the data shown without the possibility to dynamically adjust it.
Parameters: request – The request to use to fill this table model.
-
sortCacheExpression
(self) → str¶ The expression which was used to fill the sorting cache
-
swapRows
(self, a: int, b: int)¶ Swaps two rows
Parameters: - a – first row
- b – second row
-
timerEvent
()¶
-