Class: QgsAggregateMappingWidget

The QgsAggregateMappingWidget class creates a mapping for defining sets of aggregates of fields from a QgsFields object.

Added in version 3.14.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsAggregateMappingWidget

Base classes

QgsPanelWidget

Base class for any widget that can be shown as a inline panel

QWidget

QObject

QPaintDevice

Methods

appendField

Appends a new field to the model, with an optional source and aggregate

mapping

Returns a list of Aggregate objects representing the current status of the underlying mapping model

model

Returns the underlying mapping model

moveSelectedFieldsDown

Moves down currently selected field

moveSelectedFieldsUp

Moves up currently selected field

registerExpressionContextGenerator

Register an expression context generator class that will be used to retrieve an expression context for the widget.

removeSelectedFields

Removes the currently selected field from the model

scrollTo

Scroll the fields view to index

selectionModel

Returns the selection model

setMapping

Sets the mapping to show in the model.

setSourceFields

Set source fields of the underlying mapping model to sourceFields

setSourceLayer

Sets a source layer to use when generating expression previews in the widget.

sourceLayer

Returns the source layer for use when generating expression previews.

Signals

changed

Emitted when the aggregates defined in the widget are changed.

class qgis.gui.QgsAggregateMappingWidget[source]

Bases: QgsPanelWidget

__init__(parent: QWidget | None = None, sourceFields: QgsFields = QgsFields())

Constructs a QgsAggregateMappingWidget from a set of sourceFields. A parent object can also be specified.

Parameters:
  • parent (Optional[QWidget] = None)

  • sourceFields (QgsFields = QgsFields())

appendField(self, field: QgsField, source: str | None = '', aggregate: str | None = '')[source]

Appends a new field to the model, with an optional source and aggregate

Parameters:
  • field (QgsField)

  • source (Optional[str] = '')

  • aggregate (Optional[str] = '')

signal changed[source]

Emitted when the aggregates defined in the widget are changed.

mapping(self) List[QgsAggregateMappingModel.Aggregate]

Returns a list of Aggregate objects representing the current status of the underlying mapping model

Return type:

List[QgsAggregateMappingModel.Aggregate]

model(self) QgsAggregateMappingModel | None[source]

Returns the underlying mapping model

Return type:

Optional[QgsAggregateMappingModel]

moveSelectedFieldsDown(self) bool[source]

Moves down currently selected field

Return type:

bool

moveSelectedFieldsUp(self) bool[source]

Moves up currently selected field

Return type:

bool

registerExpressionContextGenerator(self, generator: QgsExpressionContextGenerator | None)[source]

Register an expression context generator class that will be used to retrieve an expression context for the widget.

Parameters:

generator (Optional[QgsExpressionContextGenerator])

removeSelectedFields(self) bool[source]

Removes the currently selected field from the model

Return type:

bool

scrollTo(self, index: QModelIndex)[source]

Scroll the fields view to index

Parameters:

index (QModelIndex)

selectionModel(self) QItemSelectionModel | None[source]

Returns the selection model

Return type:

Optional[QItemSelectionModel]

setMapping(self, mapping: Iterable[QgsAggregateMappingModel.Aggregate])[source]

Sets the mapping to show in the model.

Parameters:

mapping (Iterable[QgsAggregateMappingModel.Aggregate])

setSourceFields(self, sourceFields: QgsFields)[source]

Set source fields of the underlying mapping model to sourceFields

Parameters:

sourceFields (QgsFields)

setSourceLayer(self, layer: QgsVectorLayer | None)[source]

Sets a source layer to use when generating expression previews in the widget.

Added in version 3.16.

Parameters:

layer (Optional[QgsVectorLayer])

sourceLayer(self) QgsVectorLayer | None[source]

Returns the source layer for use when generating expression previews.

Returned value may be None.

Added in version 3.16.

Return type:

Optional[QgsVectorLayer]