Class: QgsAttributeFormWidget

class qgis.gui.QgsAttributeFormWidget

Bases: PyQt5.QtWidgets.QWidget

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.

New in version 3.0.

QgsAttributeFormWidget(widget: QgsWidgetWrapper, form: QgsAttributeForm) A new form widget for the wrapper widget on 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

AggregateSearchMode = 3
DefaultMode = 0
class Mode

Bases: int

MultiEditMode = 1
SearchMode = 2
addAdditionalSearchWidgetWrapper(self, wrapper: QgsSearchWidgetWrapper)

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

Parameters:

wrapper (QgsSearchWidgetWrapper) –

createSearchWidgetWrappers(self)

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

currentFilterExpression(self) str

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

New in version 2.16.

Return type:

str

form(self) QgsAttributeForm

The form on which this widget is shown.

Return type:

QgsAttributeForm

layer(self) QgsVectorLayer

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

Return type:

QgsVectorLayer

mode(self) QgsAttributeFormWidget.Mode

Returns the current mode for the widget.

See also

setMode()

Return type:

QgsAttributeFormWidget.Mode

resetSearch(self)

Resets the search/filter value of the widget.

searchWidgetToolButtonVisible(self) bool

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)

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)

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)

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

Parameters:

wrapper (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