Class: 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.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsAttributeTableView

Base classes

QgsTableView

A QTableView subclass with QGIS specific tweaks and improvements.

QTableView

QAbstractItemView

QAbstractScrollArea

QFrame

QWidget

QObject

QPaintDevice

Methods

closeCurrentEditor

Closes the editor delegate for the current item, committing its changes to the model.

closeEvent

Saves geometry to the settings on close

contextMenuEvent

Is called when the context menu will be shown.

eventFilter

This event filter is installed on the verticalHeader to intercept mouse press and release events.

keyPressEvent

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

mouseMoveEvent

Called for mouse move events on a table cell.

mousePressEvent

Called for mouse press events on a table cell.

mouseReleaseEvent

Called for mouse release events on a table cell.

repaintRequested

scrollToFeature

Scroll to a feature with a given fid.

selectedFeaturesIds

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

setAttributeTableConfig

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

setFeatureSelectionManager

setFeatureSelectionManager

Signals

columnResized

Emitted when a column in the view has been resized.

finished

willShowContextMenu

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

class qgis.gui.QgsAttributeTableView[source]

Bases: QgsTableView

__init__(parent: QWidget | None = None)

Constructor for QgsAttributeTableView

Parameters:

parent (Optional[QWidget] = None)

closeCurrentEditor(self)[source]

Closes the editor delegate for the current item, committing its changes to the model.

Added in version 3.30.

closeEvent(self, event: QCloseEvent | None)[source]

Saves geometry to the settings on close

Parameters:

event (Optional[QCloseEvent]) – not used

signal columnResized(column: int, width: int)[source]

Emitted when a column in the view has been resized.

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

  • width (int) – new width in pixel

contextMenuEvent(self, event: QContextMenuEvent | None)[source]

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.

Parameters:

event (Optional[QContextMenuEvent]) – The associated event object.

eventFilter(self, object: QObject | None, event: QEvent | None) bool[source]

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.

Parameters:
  • object (Optional[QObject]) – The object which is the target of the event.

  • event (Optional[QEvent]) – The intercepted event

Return type:

bool

Returns:

Returns always False, so the event gets processed

signal finished[source]

Deprecated since version 3.40: No longer used.

keyPressEvent(self, event: QKeyEvent | None)[source]

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

Parameters:

event (Optional[QKeyEvent]) – The mouse event

mouseMoveEvent(self, event: QMouseEvent | None)[source]

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

Parameters:

event (Optional[QMouseEvent]) – The mouse event

mousePressEvent(self, event: QMouseEvent | None)[source]

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

Parameters:

event (Optional[QMouseEvent]) – The mouse event

mouseReleaseEvent(self, event: QMouseEvent | None)[source]

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

Parameters:

event (Optional[QMouseEvent]) – The mouse event

repaintRequested(self, indexes: Iterable[QModelIndex])[source]
repaintRequested(self) None
Parameters:

indexes (Iterable[QModelIndex])

repaintRequested(self)[source]
scrollToFeature(self, fid: int, column: int = -1)[source]

Scroll to a feature with a given fid.

Optionally a column can be specified, which will also bring that column into view.

Added in version 3.16.

Parameters:
  • fid (int)

  • column (int = -1)

selectedFeaturesIds(self) List[int]

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

Return type:

List[int]

Returns:

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

Added in version 3.4.

setAttributeTableConfig(self, config: QgsAttributeTableConfig)[source]

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

Parameters:

config (QgsAttributeTableConfig)

setFeatureSelectionManager(self, featureSelectionManager: QgsIFeatureSelectionManager | None)[source]
setFeatureSelectionManager(None) None
Parameters:

featureSelectionManager (Optional[QgsIFeatureSelectionManager])

signal willShowContextMenu(menu: QMenu, atIndex: QModelIndex)[source]

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

Parameters:
  • 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