Subgroup: Attribute

Class: QgsAttributeFormWidget

class qgis.gui.QgsAttributeFormWidget(widget: QgsWidgetWrapper, form: QgsAttributeForm)

Bases: PyQt5.QtWidgets.QWidget

A new form widget for the wrapper widget on form.

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

Signals

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.

createSearchWidgetWrappers(self)

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

Parameters:context – editor context (not available in Python bindings)
currentFilterExpression(self) → str

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

New in version 2.16.

form(self) → QgsAttributeForm

The form on which this widget is shown.

layer(self) → QgsVectorLayer

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

mode(self) → QgsAttributeFormWidget.Mode

Returns the current mode for the widget.

See also

setMode()

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.

searchWidgetWrappers(self) → object

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

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 – 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.

setSearchWidgetWrapper(self, wrapper: QgsSearchWidgetWrapper)

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

Parameters:wrapper – 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