Class: QgsAttributeDialog

An attribute table dialog for a vector layer.

QgsAttributeDialog in QgsAttributeEditorContext.Mode.SingleEditMode

QgsAttributeDialog in QgsAttributeEditorContext.Mode.SingleEditMode

Class Hierarchy

Inheritance diagram of qgis.gui.QgsAttributeDialog

Base classes

QDialog

QWidget

QObject

QPaintDevice

QgsMapLayerActionContextGenerator

An interface for objects which can create a QgsMapLayerActionContext.

class qgis.gui.QgsAttributeDialog[source]

Bases: QDialog, QgsMapLayerActionContextGenerator

__init__(vl: QgsVectorLayer | None, thepFeature: QgsFeature | None, featureOwner: bool, parent: QWidget | None = None, showDialogButtons: bool = True, context: QgsAttributeEditorContext = QgsAttributeEditorContext())

Create an attribute dialog for a given layer and feature

Parameters:
  • vl (Optional[QgsVectorLayer]) – The layer for which the dialog will be generated

  • thepFeature (Optional[QgsFeature]) – A feature for which the dialog will be generated

  • featureOwner (bool) – Set to True, if the dialog should take ownership of the feature

  • parent (Optional[QWidget] = None) – A parent widget for the dialog

  • showDialogButtons (bool = True) – True: Show the dialog buttons accept/cancel

  • context (QgsAttributeEditorContext = QgsAttributeEditorContext()) – The context in which this dialog is created

attributeForm(self) QgsAttributeForm | None[source]

Returns the attribute form.

Return type:

Optional[QgsAttributeForm]

editable(self) bool[source]

Is this dialog editable?

Return type:

bool

Returns:

returns True, if this dialog was created in an editable manner.

virtual event(self, e: QEvent | None) bool[source]

Intercept window activate/deactivate events to show/hide the highlighted feature.

Parameters:

e (Optional[QEvent]) – The event

Return type:

bool

Returns:

The same as the parent QDialog

feature(self) QgsFeature | None[source]

Returns the current feature of the attribute form.

Return type:

Optional[QgsFeature]

setEditCommandMessage(self, message: str | None)[source]

Sets the edit command message (Undo) that will be used when the dialog is accepted

Parameters:

message (Optional[str]) – The message

setExtraContextScope(self, extraScope: QgsExpressionContextScope | None)[source]

Sets extraScope as an additional expression context scope to be used for calculations in this form.

Added in version 3.16.

Parameters:

extraScope (Optional[QgsExpressionContextScope])

setHighlight(self, h: QgsHighlight | None)[source]
setHighlight()
Parameters:

h (Optional[QgsHighlight]) – The highlight. Ownership is taken.

setMode(self, mode: QgsAttributeEditorContext.Mode)[source]

Toggles the form mode.

Parameters:

mode (QgsAttributeEditorContext.Mode) – form mode. For example, if set to QgsAttributeEditorContext.AddFeatureMode, the dialog will be editable even with an invalid feature and will add a new feature when the form is accepted.

show(self)[source]

Show the dialog non-blocking. Reparents this dialog to be a child of the dialog form