Class: QgsFieldMappingWidget¶
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 an inline panel. |
|
- class qgis.gui.QgsFieldMappingWidget[source]¶
Bases:
QgsPanelWidget- __init__(parent: QWidget | None = None, sourceFields: QgsFields = QgsFields(), destinationFields: QgsFields = QgsFields(), expressions: Dict[str | None, str | None] = {}, nativeTypes: Iterable[QgsVectorDataProvider.NativeType] = [])
Constructs a QgsFieldMappingWidget from a set of
sourceFieldsanddestinationFields, initial values for the expressions can be optionally specified throughexpressionswhich is a map from the original field name to the corresponding expression. Aparentobject can also be specified.Since QGIS 3.44, the
nativeTypesargument can be used to specify the list of field types natively supported by a data provider. If this list is non-empty, then the destination field types will be populated accordingly. If the list is empty, then a set of default native types will be used instead.- Parameters:
parent (Optional[QWidget] = None)
sourceFields (
QgsFields= QgsFields())destinationFields (
QgsFields= QgsFields())expressions (Dict[Optional[str], Optional[str]] = {})
nativeTypes (Iterable[QgsVectorDataProvider.NativeType] = [])
- appendField(self, field: QgsField, expression: str | None = '')[source]¶
Appends a new
fieldto the model, with an optionalexpression- Parameters:
field (QgsField)
expression (Optional[str] = '')
- signal changed[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- destinationEditable(self) bool[source]¶
Returns
Trueif the destination fields are editable in the model- Return type:
bool
- fieldPropertyMap(self) Dict[str, QgsProperty]¶
Returns a map of destination field name to
QgsPropertydefinition 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
generatorclass 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
destinationFieldsin the underlying model, initial values for the expressions can be optionally specified throughexpressionswhich 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
QgsPropertydefinition for field value.See also
- Parameters:
map (Dict[Optional[str], QgsProperty])
- setNativeTypes(self, nativeTypes: Iterable[QgsVectorDataProvider.NativeType])[source]¶
Sets the list of
nativeTypessupported by a data provider.If this list is non-empty, then the destination field types will be populated accordingly. If the list is empty, then a set of default native types will be used instead.
Added in version 3.44.
- Parameters:
nativeTypes (Iterable[QgsVectorDataProvider.NativeType])
- 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
layerto 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]