Class: QgsFieldMappingWidget¶
The QgsFieldMappingWidget
class creates a mapping from one
set of QgsFields
to another, for each set of “destination”
fields an expression defines how to obtain the values of the
“destination” fields.
Added in version 3.14.
Class Hierarchy¶
Base classes¶
Base class for any widget that can be shown as a inline panel |
|
Methods
Appends a new field to the model, with an optional expression |
|
Returns |
|
Returns a map of destination field name to |
|
Invert the field selection state. |
|
Returns a list of Field objects representing the current status of the underlying mapping model |
|
Returns the underlying mapping model |
|
Moves down the currently selected field |
|
Moves up currently selected field |
|
Register an expression context generator class that will be used to retrieve an expression context for the widget. |
|
Removes the currently selected field from the model |
|
Scroll the fields view to index |
|
Returns the selection model |
|
Sets the destination fields editable state to editable |
|
Set destination fields to destinationFields in the underlying model, initial values for the expressions can be optionally specified through expressions which is a map from the original field name to the corresponding expression. |
|
Sets a map of destination field name to |
|
Set source fields of the underlying mapping model to sourceFields |
|
Sets a source layer to use when generating expression previews in the widget. |
|
Returns the source layer for use when generating expression previews. |
Signals
Emitted when the fields defined in the widget are changed. |
- class qgis.gui.QgsFieldMappingWidget[source]¶
Bases:
QgsPanelWidget
- __init__(parent: QWidget | None = None, sourceFields: QgsFields = QgsFields(), destinationFields: QgsFields = QgsFields(), expressions: Dict[str | None, str | None] = {})
Constructs a QgsFieldMappingWidget from a set of
sourceFields
anddestinationFields
, initial values for the expressions can be optionally specified throughexpressions
which is a map from the original field name to the corresponding expression. Aparent
object can also be specified.
- appendField(self, field: QgsField, expression: str | None = '')[source]¶
Appends a new
field
to the model, with an optionalexpression
- Parameters:
field (QgsField)
expression (Optional[str] = '')
- destinationEditable(self) bool [source]¶
Returns
True
if the destination fields are editable in the model- Return type:
bool
- fieldPropertyMap(self) Dict[str, QgsProperty] ¶
Returns a map of destination field name to
QgsProperty
definition for field value, representing the current status of the widget.See also
- Return type:
Dict[str, QgsProperty]
- mapping(self) List[QgsFieldMappingModel.Field] ¶
Returns a list of Field objects representing the current status of the underlying mapping model
- Return type:
- model(self) QgsFieldMappingModel | None [source]¶
Returns the underlying mapping model
- Return type:
Optional[QgsFieldMappingModel]
- moveSelectedFieldsDown(self) bool [source]¶
Moves down the 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]
- setDestinationEditable(self, editable: bool)[source]¶
Sets the destination fields editable state to
editable
- Parameters:
editable (bool)
- setDestinationFields(self, destinationFields: QgsFields, expressions: Dict[str | None, str | None] = {})[source]¶
Set destination fields to
destinationFields
in the underlying model, initial values for the expressions can be optionally specified throughexpressions
which is a map from the original field name to the corresponding expression.- Parameters:
destinationFields (QgsFields)
expressions (Dict[Optional[str], Optional[str]] = {})
- setFieldPropertyMap(self, map: Dict[str | None, QgsProperty])[source]¶
Sets a map of destination field name to
QgsProperty
definition for field value.See also
- Parameters:
map (Dict[Optional[str], QgsProperty])
- 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]