Class: QgsAttributeTableView

class qgis.gui.QgsAttributeTableView(parent: QWidget = None)

Bases: PyQt5.QtWidgets.QTableView

Constructor for QgsAttributeTableView

Provides a table view of features of a QgsVectorLayer.

This can either be used as a standalone widget. QgsBrowser features a reference implementation. Or this can be used within the QgsDualView stacked widget.



actionEvent(self, QActionEvent)
changeEvent(self, QEvent)
childEvent(self, QChildEvent)
closeEditor(self, QWidget, QAbstractItemDelegate.EndEditHint)
closeEvent(self, event: QCloseEvent)

Saves geometry to the settings on close


event (QCloseEvent) – not used

QgsAttributeTableView.columnCountChanged(self, int, int)
QgsAttributeTableView.columnMoved(self, int, int, int)

Emitted when a column in the view has been resized.

  • column (int) – column index (starts at 0)

  • width (int) – new width in pixel

New in version 2.16: [signal]

commitData(self, QWidget)
connectNotify(self, QMetaMethod)
contextMenuEvent(self, event: QContextMenuEvent)

Is called when the context menu will be shown. Emits a willShowContextMenu() signal, so the menu can be populated by other parts of the application.


event (QContextMenuEvent) – The associated event object.

create(self, window: sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)
QgsAttributeTableView.currentChanged(self, QModelIndex, QModelIndex)
customEvent(self, QEvent)
QgsAttributeTableView.dataChanged(self, QModelIndex, QModelIndex, roles: Iterable[int] = [])
destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
dirtyRegionOffset(self) → QPoint
disconnectNotify(self, QMetaMethod)
dragEnterEvent(self, QDragEnterEvent)
dragLeaveEvent(self, QDragLeaveEvent)
dragMoveEvent(self, QDragMoveEvent)
drawFrame(self, QPainter)
dropEvent(self, QDropEvent)
dropIndicatorPosition(self) → QAbstractItemView.DropIndicatorPosition
edit(self, QModelIndex)

edit(self, QModelIndex, QAbstractItemView.EditTrigger, QEvent) -> bool

editorDestroyed(self, QObject)
enterEvent(self, QEvent)
event(self, QEvent) → bool
eventFilter(self, object: QObject, event: QEvent) → bool

This event filter is installed on the verticalHeader to intercept mouse press and release events. These are used to disable / enable live synchronisation with the map canvas selection which can be slow due to recurring canvas repaints.

  • object (QObject) – The object which is the target of the event.

  • event (QEvent) – The intercepted event

Return type



Returns always False, so the event gets processed


finished(self) [signal]

focusInEvent(self, QFocusEvent)
focusNextChild(self) → bool
focusNextPrevChild(self, bool) → bool
focusOutEvent(self, QFocusEvent)
focusPreviousChild(self) → bool
hideEvent(self, QHideEvent)
horizontalOffset(self) → int
horizontalScrollbarAction(self, int)
horizontalScrollbarValueChanged(self, int)
initPainter(self, QPainter)
initStyleOption(self, QStyleOptionFrame)
inputMethodEvent(self, QInputMethodEvent)
isIndexHidden(self, QModelIndex) → bool
isSignalConnected(self, QMetaMethod) → bool
keyPressEvent(self, event: QKeyEvent)

Called for key press events Disables selection change by only pressing an arrow key


event (QKeyEvent) – The mouse event

keyReleaseEvent(self, QKeyEvent)
leaveEvent(self, QEvent)
metric(self, QPaintDevice.PaintDeviceMetric) → int
mouseDoubleClickEvent(self, QMouseEvent)
mouseMoveEvent(self, event: QMouseEvent)

Called for mouse move events on a table cell. Disables selection change for these events.


event (QMouseEvent) – The mouse event

mousePressEvent(self, event: QMouseEvent)

Called for mouse press events on a table cell. Disables selection change for these events.


event (QMouseEvent) – The mouse event

mouseReleaseEvent(self, event: QMouseEvent)

Called for mouse release events on a table cell. Disables selection change for these events.


event (QMouseEvent) – The mouse event

moveCursor(self, QAbstractItemView.CursorAction, Union[Qt.KeyboardModifiers, Qt.KeyboardModifier]) → QModelIndex
moveEvent(self, QMoveEvent)
nativeEvent(self, Union[QByteArray, bytes, bytearray], sip.voidptr) → Tuple[bool, int]
paintEvent(self, QPaintEvent)
receivers(self, PYQT_SIGNAL) → int
repaintRequested(self, indexes: Iterable[QModelIndex])



indexes (Iterable[QModelIndex]) –

resizeEvent(self, QResizeEvent)
QgsAttributeTableView.rowCountChanged(self, int, int)
QgsAttributeTableView.rowMoved(self, int, int, int)
QgsAttributeTableView.rowResized(self, int, int, int)
QgsAttributeTableView.rowsAboutToBeRemoved(self, QModelIndex, int, int)
QgsAttributeTableView.rowsInserted(self, QModelIndex, int, int)
QgsAttributeTableView.scrollContentsBy(self, int, int)
QgsAttributeTableView.scrollDirtyRegion(self, int, int)
selectRow(self, row: int)

row (int) –

selectedFeaturesIds(self) → object

Returns the selected features in the attribute table in table sorted order.

Return type



The selected features in the attribute table in the order sorted by the table.

New in version 3.4.

selectedIndexes(self) → List[QModelIndex]
QgsAttributeTableView.selectionChanged(self, QItemSelection, QItemSelection)
selectionCommand(self, QModelIndex, event: QEvent = None) → QItemSelectionModel.SelectionFlags
sender(self) → QObject
senderSignalIndex(self) → int
setAttributeTableConfig(self, config: QgsAttributeTableConfig)

Set the attribute table config which should be used to control the appearance of the attribute table.

New in version 2.16.


config (QgsAttributeTableConfig) –

setDirtyRegion(self, QRegion)
setFeatureSelectionManager(self, featureSelectionManager: QgsIFeatureSelectionManager)



featureSelectionManager (QgsIFeatureSelectionManager) –

setModel(self, filterModel: QgsAttributeTableFilterModel)

filterModel (QgsAttributeTableFilterModel) –

setSelection(self, QRect, Union[QItemSelectionModel.SelectionFlags, QItemSelectionModel.SelectionFlag])
setState(self, QAbstractItemView.State)
QgsAttributeTableView.setViewportMargins(self, int, int, int, int)

setViewportMargins(self, QMargins)

sharedPainter(self) → QPainter
showEvent(self, QShowEvent)
sizeHintForColumn(self, int) → int
sizeHintForRow(self, int) → int
startDrag(self, Union[Qt.DropActions, Qt.DropAction])
state(self) → QAbstractItemView.State
tabletEvent(self, QTabletEvent)
timerEvent(self, QTimerEvent)
verticalOffset(self) → int
verticalScrollbarAction(self, int)
verticalScrollbarValueChanged(self, int)
viewOptions(self) → QStyleOptionViewItem
viewportEvent(self, QEvent) → bool
viewportMargins(self) → QMargins
viewportSizeHint(self) → QSize
visualRegionForSelection(self, QItemSelection) → QRegion
wheelEvent(self, QWheelEvent)

Emitted in order to provide a hook to add additional* menu entries to the context menu.

  • menu (QMenu) – If additional QMenuItems are added, they will show up in the context menu.

  • atIndex (QModelIndex) – The QModelIndex, to which the context menu belongs. Relative to the source model. In most cases, this will be a QgsAttributeTableFilterModel [signal]