Class: QgsAttributeFormWidget

Base class for all widgets shown on a QgsAttributeForm. Consists of the widget which is visible in edit mode as well as the widget visible in search mode.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsAttributeFormWidget

Base classes

QWidget

QObject

QPaintDevice

Subclasses

QgsAttributeFormEditorWidget

A widget consisting of both an editor widget and additional widgets for controlling the behavior of the editor widget depending on a number of possible modes. For instance, if the parent attribute form is in the multi edit mode, this widget will show both the editor widget and a tool button for controlling the multi edit results.

QgsAttributeFormRelationEditorWidget

Widget to show for child relations on an attribute form.

Methods

addAdditionalSearchWidgetWrapper

Adds an additional search widget wrapper.

createSearchWidgetWrappers

Creates the search widget wrappers for the widget used when the form is in search mode.

currentFilterExpression

Creates an expression matching the current search filter value and search properties represented in the widget.

form

The form on which this widget is shown.

layer

The layer for which this widget and its form is shown.

mode

Returns the current mode for the widget.

resetSearch

Resets the search/filter value of the widget.

searchWidgetToolButtonVisible

The visibility of the search widget tool button, that allows (de)activating this search widgte or defines the comparison operator to use.

searchWidgetWrappers

Returns the search widget wrapper used in this widget.

setMode

Sets the current mode for the widget.

setSearchWidgetToolButtonVisible

The visibility of the search widget tool button, that allows (de)activating this search widgte or defines the comparison operator to use.

setSearchWidgetWrapper

Sets the search widget wrapper for the widget used when the form is in search mode.

Attributes

AggregateSearchMode

DefaultMode

MultiEditMode

SearchMode

class qgis.gui.QgsAttributeFormWidget[source]

Bases: QWidget

__init__(widget: QgsWidgetWrapper | None, form: QgsAttributeForm | None)

A new form widget for the wrapper widget on form.

Parameters:
AggregateSearchMode = 3
DefaultMode = 0
class Mode

Bases: int

MultiEditMode = 1
SearchMode = 2
addAdditionalSearchWidgetWrapper(self, wrapper: QgsSearchWidgetWrapper | None)[source]

Adds an additional search widget wrapper. Used to register a secondary search widget as used for “between” searches.

Parameters:

wrapper (Optional[QgsSearchWidgetWrapper])

createSearchWidgetWrappers(self)[source]

Creates the search widget wrappers for the widget used when the form is in search mode.

currentFilterExpression(self) str[source]

Creates an expression matching the current search filter value and search properties represented in the widget.

Return type:

str

form(self) QgsAttributeForm | None[source]

The form on which this widget is shown.

Return type:

Optional[QgsAttributeForm]

layer(self) QgsVectorLayer | None[source]

The layer for which this widget and its form is shown.

Return type:

Optional[QgsVectorLayer]

mode(self) QgsAttributeFormWidget.Mode[source]

Returns the current mode for the widget.

See also

setMode()

Return type:

QgsAttributeFormWidget.Mode

resetSearch(self)[source]

Resets the search/filter value of the widget.

searchWidgetToolButtonVisible(self) bool[source]

The visibility of the search widget tool button, that allows (de)activating this search widgte or defines the comparison operator to use.

Return type:

bool

searchWidgetWrappers(self) List[QgsSearchWidgetWrapper]

Returns the search widget wrapper used in this widget. The wrapper must first be created using createSearchWidgetWrapper()

Note

this method is in place for unit testing only, and is not considered stable API

Return type:

List[QgsSearchWidgetWrapper]

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

Sets the current mode for the widget. The widget will adapt its state and visible widgets to reflect the updated mode. For example, showing multi edit tool buttons if the mode is set to MultiEditMode.

Parameters:

mode (QgsAttributeFormWidget.Mode) – widget mode

See also

mode()

setSearchWidgetToolButtonVisible(self, searchWidgetToolButtonVisible: bool)[source]

The visibility of the search widget tool button, that allows (de)activating this search widgte or defines the comparison operator to use.

Parameters:

searchWidgetToolButtonVisible (bool)

setSearchWidgetWrapper(self, wrapper: QgsSearchWidgetWrapper | None)[source]

Sets the search widget wrapper for the widget used when the form is in search mode.

Parameters:

wrapper (Optional[QgsSearchWidgetWrapper]) – search widget wrapper.

Note

the search widget wrapper should be created using searchWidgetFrame() as its parent

Note

this method is in place for unit testing only, and is not considered stable API