Class: QgsFieldMappingWidget

class qgis.gui.QgsFieldMappingWidget

Bases: QgsPanelWidget

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.

QgsFieldMappingWidget(parent: Optional[QWidget] = None, sourceFields: QgsFields = QgsFields(), destinationFields: QgsFields = QgsFields(), expressions: Dict[Optional[str], Optional[str]] = {}) Constructs a QgsFieldMappingWidget from a set of sourceFields and destinationFields, initial values for the expressions can be optionally specified through expressions which is a map from the original field name to the corresponding expression. A parent object can also be specified.

Methods

actionEvent

appendField

Appends a new field to the model, with an optional expression

changeEvent

childEvent

closeEvent

connectNotify

contextMenuEvent

create

customEvent

destinationEditable

Returns True if the destination fields are editable in the model

destroy

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

dropEvent

enterEvent

event

fieldPropertyMap

Returns a map of destination field name to QgsProperty definition for field value, representing the current status of the widget.

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPreviousChild

hideEvent

initPainter

inputMethodEvent

invertSelection

Invert the field selection state.

isSignalConnected

keyPressEvent

Overridden key press event to handle the esc event on the widget.

keyReleaseEvent

leaveEvent

mapping

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

metric

model

Returns the underlying mapping model

mouseDoubleClickEvent

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

moveEvent

moveSelectedFieldsDown

Moves down the currently selected field

moveSelectedFieldsUp

Moves up currently selected field

nativeEvent

paintEvent

receivers

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

resizeEvent

scrollTo

Scroll the fields view to index

selectionModel

Returns the selection model

sender

senderSignalIndex

setDestinationEditable

Sets the destination fields editable state to editable

setDestinationFields

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.

setFieldPropertyMap

Sets a map of destination field name to QgsProperty definition for field value.

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.

sharedPainter

showEvent

sourceLayer

Returns the source layer for use when generating expression previews.

tabletEvent

timerEvent

updateMicroFocus

wheelEvent

Signals

changed

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

actionEvent(self, a0: QActionEvent | None)
appendField(self, field: QgsField, expression: str | None = '')

Appends a new field to the model, with an optional expression

Parameters:
  • field (QgsField)

  • expression (Optional[str] = '')

changeEvent(self, a0: QEvent | None)
changed

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.

Parameters:
  • name (str = ...)

  • revision (int = ...)

  • arguments (Sequence = ...)

Return type:

PYQT_SIGNAL

childEvent(self, a0: QChildEvent | None)
closeEvent(self, a0: QCloseEvent | None)
connectNotify(self, signal: QMetaMethod)
contextMenuEvent(self, a0: QContextMenuEvent | None)
create(self, window: PyQt5.sip.voidptr = None, initializeWindow: bool = True, destroyOldWindow: bool = True)
customEvent(self, a0: QEvent | None)
destinationEditable(self) bool

Returns True if the destination fields are editable in the model

Return type:

bool

destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
disconnectNotify(self, signal: QMetaMethod)
dragEnterEvent(self, a0: QDragEnterEvent | None)
dragLeaveEvent(self, a0: QDragLeaveEvent | None)
dragMoveEvent(self, a0: QDragMoveEvent | None)
dropEvent(self, a0: QDropEvent | None)
enterEvent(self, a0: QEvent | None)
event(self, a0: QEvent | None) 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.

Return type:

Dict[str, QgsProperty]

focusInEvent(self, a0: QFocusEvent | None)
focusNextChild(self) bool
focusNextPrevChild(self, next: bool) bool
focusOutEvent(self, a0: QFocusEvent | None)
focusPreviousChild(self) bool
hideEvent(self, a0: QHideEvent | None)
initPainter(self, painter: QPainter | None)
inputMethodEvent(self, a0: QInputMethodEvent | None)
invertSelection(self)

Invert the field selection state.

Added in version 3.32.

isSignalConnected(self, signal: QMetaMethod) bool
keyPressEvent(self, event: QKeyEvent | None)

Overridden key press event to handle the esc event on the widget.

Parameters:

event – The key event

keyReleaseEvent(self, a0: QKeyEvent | None)
leaveEvent(self, a0: QEvent | None)
mapping(self) List[QgsFieldMappingModel.Field]

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

Return type:

List[QgsFieldMappingModel.Field]

metric(self, a0: QPaintDevice.PaintDeviceMetric) int
model(self) QgsFieldMappingModel | None

Returns the underlying mapping model

Return type:

Optional[QgsFieldMappingModel]

mouseDoubleClickEvent(self, a0: QMouseEvent | None)
mouseMoveEvent(self, a0: QMouseEvent | None)
mousePressEvent(self, a0: QMouseEvent | None)
mouseReleaseEvent(self, a0: QMouseEvent | None)
moveEvent(self, a0: QMoveEvent | None)
moveSelectedFieldsDown(self) bool

Moves down the currently selected field

Return type:

bool

moveSelectedFieldsUp(self) bool

Moves up currently selected field

Return type:

bool

nativeEvent(self, eventType: QByteArray | bytes | bytearray, message: PyQt5.sip.voidptr | None)
paintEvent(self, a0: QPaintEvent | None)
receivers(self, signal: PYQT_SIGNAL) int
registerExpressionContextGenerator(self, generator: QgsExpressionContextGenerator | None)

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

Removes the currently selected field from the model

Return type:

bool

resizeEvent(self, a0: QResizeEvent | None)
scrollTo(self, index: QModelIndex)

Scroll the fields view to index

Parameters:

index (QModelIndex)

selectionModel(self) QItemSelectionModel | None

Returns the selection model

Return type:

Optional[QItemSelectionModel]

sender(self) QObject | None
senderSignalIndex(self) int
setDestinationEditable(self, editable: bool)

Sets the destination fields editable state to editable

Parameters:

editable (bool)

setDestinationFields(self, destinationFields: QgsFields, expressions: Dict[str | None, str | None] = {})

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.

Parameters:
  • destinationFields (QgsFields)

  • expressions (Dict[Optional[str])

setFieldPropertyMap(self, map: Dict[str | None, QgsProperty])

Sets a map of destination field name to QgsProperty definition for field value.

Parameters:

map (Dict[Optional[str])

setSourceFields(self, sourceFields: QgsFields)

Set source fields of the underlying mapping model to sourceFields

Parameters:

sourceFields (QgsFields)

setSourceLayer(self, layer: QgsVectorLayer | None)

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

Added in version 3.16.

Parameters:

layer (Optional[QgsVectorLayer])

sharedPainter(self) QPainter | None
showEvent(self, a0: QShowEvent | None)
sourceLayer(self) QgsVectorLayer | None

Returns the source layer for use when generating expression previews.

Returned value may be None.

Added in version 3.16.

Return type:

Optional[QgsVectorLayer]

tabletEvent(self, a0: QTabletEvent | None)
timerEvent(self, a0: QTimerEvent | None)
updateMicroFocus(self)
wheelEvent(self, a0: QWheelEvent | None)