Class: QgsAttributeTableView

class qgis.gui.QgsAttributeTableView

Bases: PyQt5.QtWidgets.QTableView

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.

QgsAttributeTableView(parent: QWidget = None) Constructor for QgsAttributeTableView

Methods

actionEvent

changeEvent

childEvent

closeEditor

closeEvent

Saves geometry to the settings on close

columnCountChanged

columnMoved

commitData

connectNotify

contextMenuEvent

Is called when the context menu will be shown.

create

currentChanged

customEvent

dataChanged

destroy

dirtyRegionOffset

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

drawFrame

dropEvent

dropIndicatorPosition

edit

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

editorDestroyed

enterEvent

event

eventFilter

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

executeDelayedItemsLayout

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPreviousChild

hideEvent

horizontalOffset

horizontalScrollbarAction

horizontalScrollbarValueChanged

initPainter

initStyleOption

inputMethodEvent

isIndexHidden

isSignalConnected

keyPressEvent

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

keyReleaseEvent

leaveEvent

metric

mouseDoubleClickEvent

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.

moveCursor

moveEvent

nativeEvent

paintEvent

receivers

repaintRequested

repaintRequested(self)

resizeEvent

rowCountChanged

rowMoved

rowResized

rowsAboutToBeRemoved

rowsInserted

scheduleDelayedItemsLayout

scrollContentsBy

scrollDirtyRegion

scrollToFeature

Scroll to a feature with a given fid.

selectAll

selectRow

param row

selectedFeaturesIds

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

selectedIndexes

selectionChanged

selectionCommand

sender

senderSignalIndex

setAttributeTableConfig

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

setDirtyRegion

setFeatureSelectionManager

setFeatureSelectionManager

setModel

param filterModel

setSelection

setState

setViewportMargins

setViewportMargins(self, QMargins)

sharedPainter

showEvent

sizeHintForColumn

sizeHintForRow

startDrag

state

tabletEvent

timerEvent

updateEditorData

updateEditorGeometries

updateGeometries

updateMicroFocus

verticalOffset

verticalScrollbarAction

verticalScrollbarValueChanged

viewOptions

viewportEvent

viewportMargins

viewportSizeHint

visualRegionForSelection

wheelEvent

Signals

columnResized

Emitted when a column in the view has been resized.

finished

finished(self) [signal]

willShowContextMenu

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

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

Parameters

event (QCloseEvent) – not used

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

Emitted when a column in the view has been resized.

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

Parameters

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.

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

  • event (QEvent) – The intercepted event

Return type

bool

Returns

Returns always False, so the event gets processed

executeDelayedItemsLayout(self)
finished

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

Parameters

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.

Parameters

event (QMouseEvent) – The mouse event

mousePressEvent(self, event: QMouseEvent)

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

Parameters

event (QMouseEvent) – The mouse event

mouseReleaseEvent(self, event: QMouseEvent)

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

Parameters

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])

repaintRequested(self)

Parameters

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)
scheduleDelayedItemsLayout(self)
QgsAttributeTableView.scrollContentsBy(self, int, int)
QgsAttributeTableView.scrollDirtyRegion(self, int, int)
scrollToFeature(self, fid: int, column: int = - 1)

Scroll to a feature with a given fid.

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

New in version 3.16.

Parameters
  • fid (int) –

  • column (int = -1) –

selectAll(self)
selectRow(self, row: int)
Parameters

row (int) –

selectedFeaturesIds(self)object

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

Return type

object

Returns

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.

Parameters

config (QgsAttributeTableConfig) –

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

setFeatureSelectionManager

Parameters

featureSelectionManager (QgsIFeatureSelectionManager) –

setModel(self, filterModel: QgsAttributeTableFilterModel)
Parameters

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)
updateEditorData(self)
updateEditorGeometries(self)
updateGeometries(self)
updateMicroFocus(self)
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)
willShowContextMenu

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 [signal]