Class: QgsFieldMappingWidget¶
- class qgis.gui.QgsFieldMappingWidget(parent: QWidget = None, sourceFields: QgsFields = QgsFields(), destinationFields: QgsFields = QgsFields(), expressions: Dict[str, str] = {})¶
Bases:
QgsPanelWidget
Constructs a
QgsFieldMappingWidget
from a set ofsourceFields
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.The
QgsFieldMappingWidget
class creates a mapping from one set ofQgsFields
to another, for each set of “destination” fields an expression defines how to obtain the values of the “destination” fields.Methods
Appends a new
field
to the model, with an optionalexpression
Returns
True
if the destination fields are editable in the modelReturns a map of destination field name to
QgsProperty
definition for field value, representing the current status of the widget.Overridden key press event to handle the esc event on the widget.
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 throughexpressions
which is a map from the original field name to the corresponding expression.Sets a map of destination field name to
QgsProperty
definition for field value.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.
- actionEvent(self, QActionEvent)¶
- appendField(self, field: QgsField, expression: str = '')¶
Appends a new
field
to the model, with an optionalexpression
- Parameters
field (QgsField) –
expression (str = '') –
- changeEvent(self, QEvent)¶
- changed¶
Emitted when the fields defined in the widget are changed. [signal]
- childEvent(self, QChildEvent)¶
- closeEvent(self, QCloseEvent)¶
- connectNotify(self, QMetaMethod)¶
- contextMenuEvent(self, QContextMenuEvent)¶
- create(self, window: sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)¶
- customEvent(self, QEvent)¶
- 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, QMetaMethod)¶
- dragEnterEvent(self, QDragEnterEvent)¶
- dragLeaveEvent(self, QDragLeaveEvent)¶
- dragMoveEvent(self, QDragMoveEvent)¶
- dropEvent(self, QDropEvent)¶
- enterEvent(self, QEvent)¶
- event(self, QEvent) → 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]
- focusInEvent(self, QFocusEvent)¶
- focusNextChild(self) → bool¶
- focusNextPrevChild(self, bool) → bool¶
- focusOutEvent(self, QFocusEvent)¶
- focusPreviousChild(self) → bool¶
- hideEvent(self, QHideEvent)¶
- initPainter(self, QPainter)¶
- inputMethodEvent(self, QInputMethodEvent)¶
- isSignalConnected(self, QMetaMethod) → bool¶
- keyPressEvent(self, event: QKeyEvent)¶
Overridden key press event to handle the esc event on the widget.
- Parameters
event – The key event
- keyReleaseEvent(self, QKeyEvent)¶
- leaveEvent(self, QEvent)¶
- mapping(self) → List[QgsFieldMappingModel.Field]¶
Returns a list of Field objects representing the current status of the underlying mapping model
- Return type
- metric(self, QPaintDevice.PaintDeviceMetric) → int¶
- model(self) → QgsFieldMappingModel¶
Returns the underlying mapping model
- Return type
- mouseDoubleClickEvent(self, QMouseEvent)¶
- mouseMoveEvent(self, QMouseEvent)¶
- mousePressEvent(self, QMouseEvent)¶
- mouseReleaseEvent(self, QMouseEvent)¶
- moveEvent(self, QMoveEvent)¶
- 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, Union[QByteArray, bytes, bytearray], sip.voidptr) → Tuple[bool, int]¶
- paintEvent(self, QPaintEvent)¶
- receivers(self, PYQT_SIGNAL) → int¶
- registerExpressionContextGenerator(self, generator: QgsExpressionContextGenerator)¶
Register an expression context
generator
class that will be used to retrieve an expression context for the widget.- Parameters
generator (QgsExpressionContextGenerator) –
- removeSelectedFields(self) → bool¶
Removes the currently selected field from the model
- Return type
bool
- resizeEvent(self, QResizeEvent)¶
- scrollTo(self, index: QModelIndex)¶
Scroll the fields view to
index
- Parameters
index (QModelIndex) –
- selectionModel(self) → QItemSelectionModel¶
Returns the selection model
- Return type
QItemSelectionModel
- sender(self) → QObject¶
- 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, str] = {})¶
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[str) –
- setFieldPropertyMap(self, map: Dict[str, QgsProperty])¶
Sets a map of destination field name to
QgsProperty
definition for field value.See also
- Parameters
map (Dict[str) –
- setSourceFields(self, sourceFields: QgsFields)¶
Set source fields of the underlying mapping model to
sourceFields
- Parameters
sourceFields (QgsFields) –
- setSourceLayer(self, layer: QgsVectorLayer)¶
Sets a source
layer
to use when generating expression previews in the widget.New in version 3.16.
- Parameters
layer (QgsVectorLayer) –
- showEvent(self, QShowEvent)¶
- sourceLayer(self) → QgsVectorLayer¶
Returns the source layer for use when generating expression previews.
Returned value may be
None
.New in version 3.16.
- Return type
- tabletEvent(self, QTabletEvent)¶
- timerEvent(self, QTimerEvent)¶
- updateMicroFocus(self)¶
- wheelEvent(self, QWheelEvent)¶