Class: QgsAbstractRelationEditorWidget¶
- class qgis.gui.QgsAbstractRelationEditorWidget¶
Bases:
PyQt5.QtWidgets.QWidget
Base class to build new relation widgets.
New in version 3.18.
QgsAbstractRelationEditorWidget(config: Dict[str, Any], parent: QWidget = None) Constructor
Methods
Adds new features with given
geometry
A hook called right after
setRelationFeature()
is executed, but beforeupdateUi()
is called.A hook called right after
setRelations()
is executed, but beforeupdateUi()
is called.A hook called right before
setRelationFeature()
is executed.A hook called right before
setRelations()
is executed.Returns the widget configuration
Delete a feature with given
fid
Deletes the features with
fids
Duplicates a feature
Duplicates features
Returns the attribute editor context.
Returns the widget's current feature If the widget is in multiedit mode only the first is returned
Returns the widget's current features
Determines the force suppress form popup status that is configured for this widget
Determines the label of this element
Links a new feature to the relation
Returns true if editing multiple features at a time
Returns the nm relation
Determines the relation id of the second relation involved in an N:M relation.
Called when the link feature dialog is confirmed by the user
Called when an
attribute
value in the parent widget has changed tonewValue
Returns the relation
Saves the current modifications in the relation
Defines the widget configuration
Sets the editor
context
Sets the
feature
being edited and updates the UI unlessupdate
is set toFalse
Sets force suppress form popup status with
forceSuppressFormPopup
configured for this widgetSets
label
for this element If it's empty it takes the relation id as labelSet multiple feature to edit simultaneously.
Sets
nmRelationId
for the relation id of the second relation involved in an N:M relation.Sets the
relation
and thefeature
Sets the relation(s) for this widget If only one relation is set, it will act as a simple 1:N relation widget If both relations are set, it will act as an N:M relation widget inserting and deleting entries on the intermediate table as required.
Defines if a title label should be shown for this widget.
Sets the title of the widget, if it is wrapped within a
QgsCollapsibleGroupBox
Refresh the UI when the widget becomes visible
Defines if a title label should be shown for this widget.
Toggles editing state of the widget
Unlinks a feature with given
fid
Unlinks the features with
fids
Updates the title contents to reflect the current state of the widget
A hook called every time the state of the relation editor widget has changed via calling its set* methods or slots, e.g.
Signals
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
- actionEvent(self, QActionEvent)¶
- addFeature(self, geometry: QgsGeometry = QgsGeometry()) object ¶
Adds new features with given
geometry
New in version 3.24.
- Parameters:
geometry (
QgsGeometry
= QgsGeometry()) –- Return type:
object
- afterSetRelationFeature(self)¶
A hook called right after
setRelationFeature()
is executed, but beforeupdateUi()
is called. Used to update the UI once setting the relation feature is done. CheckQgsRealationEditorWidget
as an example.
- afterSetRelations(self)¶
A hook called right after
setRelations()
is executed, but beforeupdateUi()
is called. Used to update the UI once setting the relations is done. CheckQgsRealationEditorWidget
as an example.
- beforeSetRelationFeature(self, newRelation: QgsRelation, newFeature: QgsFeature)¶
A hook called right before
setRelationFeature()
is executed. Used to update the UI once setting the relation feature is done. CheckQgsRealationEditorWidget
as an example.- Parameters:
newRelation (QgsRelation) –
newFeature (QgsFeature) –
- beforeSetRelations(self, newRelation: QgsRelation, newNmRelation: QgsRelation)¶
A hook called right before
setRelations()
is executed. Used to manipulate UI once setting the relations is done. CheckQgsRealationEditorWidget
as an example.- Parameters:
newRelation (QgsRelation) –
newNmRelation (QgsRelation) –
- changeEvent(self, QEvent)¶
- childEvent(self, QChildEvent)¶
- closeEvent(self, QCloseEvent)¶
- config(self) Dict[str, Any] ¶
Returns the widget configuration
- Return type:
Dict[str, Any]
- connectNotify(self, QMetaMethod)¶
- contextMenuEvent(self, QContextMenuEvent)¶
- create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)¶
- customEvent(self, QEvent)¶
- deleteFeature(self, fid: int = ::QgsFeatureId())¶
Delete a feature with given
fid
- Parameters:
fid (int = ::QgsFeatureId()) –
- deleteFeatures(self, fids: object)¶
Deletes the features with
fids
- Parameters:
fids (object) –
- destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)¶
- disconnectNotify(self, QMetaMethod)¶
- dragEnterEvent(self, QDragEnterEvent)¶
- dragLeaveEvent(self, QDragLeaveEvent)¶
- dragMoveEvent(self, QDragMoveEvent)¶
- dropEvent(self, QDropEvent)¶
- duplicateFeature(self, fid: int)¶
Duplicates a feature
- Parameters:
fid (int) –
- duplicateFeatures(self, fids: object)¶
Duplicates features
- Parameters:
fids (object) –
- editorContext(self) QgsAttributeEditorContext ¶
Returns the attribute editor context.
- Return type:
- enterEvent(self, QEvent)¶
- event(self, QEvent) bool ¶
- feature(self) QgsFeature ¶
Returns the widget’s current feature If the widget is in multiedit mode only the first is returned
See also
- Return type:
- features(self) List[QgsFeature] ¶
Returns the widget’s current features
New in version 3.24.
- Return type:
List[QgsFeature]
- focusInEvent(self, QFocusEvent)¶
- focusNextChild(self) bool ¶
- focusNextPrevChild(self, bool) bool ¶
- focusOutEvent(self, QFocusEvent)¶
- focusPreviousChild(self) bool ¶
- forceSuppressFormPopup(self) bool ¶
Determines the force suppress form popup status that is configured for this widget
- Return type:
bool
- hideEvent(self, QHideEvent)¶
- initPainter(self, QPainter)¶
- inputMethodEvent(self, QInputMethodEvent)¶
- isSignalConnected(self, QMetaMethod) bool ¶
- keyPressEvent(self, QKeyEvent)¶
- keyReleaseEvent(self, QKeyEvent)¶
- label(self) str ¶
Determines the label of this element
Deprecated since version QGIS: 3.20 label is handled directly in
QgsAttributeForm
.- Return type:
str
- leaveEvent(self, QEvent)¶
- linkFeature(self)¶
Links a new feature to the relation
- metric(self, QPaintDevice.PaintDeviceMetric) int ¶
- mouseDoubleClickEvent(self, QMouseEvent)¶
- mouseMoveEvent(self, QMouseEvent)¶
- mousePressEvent(self, QMouseEvent)¶
- mouseReleaseEvent(self, QMouseEvent)¶
- moveEvent(self, QMoveEvent)¶
- multiEditModeActive(self) bool ¶
Returns true if editing multiple features at a time
New in version 3.24.
- Return type:
bool
- nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int] ¶
- nmRelation(self) QgsRelation ¶
Returns the nm relation
New in version 3.18.
- Return type:
- nmRelationId(self) Any ¶
Determines the relation id of the second relation involved in an N:M relation.
- Return type:
Any
- onLinkFeatureDlgAccepted(self)¶
Called when the link feature dialog is confirmed by the user
- paintEvent(self, QPaintEvent)¶
- parentFormValueChanged(self, attribute: str, newValue: Any)¶
Called when an
attribute
value in the parent widget has changed tonewValue
- Parameters:
attribute (str) –
newValue (Any) –
- receivers(self, PYQT_SIGNAL) int ¶
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
- relation(self) QgsRelation ¶
Returns the relation
New in version 3.18.
- Return type:
- resizeEvent(self, QResizeEvent)¶
- saveEdits(self)¶
Saves the current modifications in the relation
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setConfig(self, config: Dict[str, Any])¶
Defines the widget configuration
- Parameters:
config (Dict[str) –
- setEditorContext(self, context: QgsAttributeEditorContext)¶
Sets the editor
context
Note
if context cadDockWidget is null, it won’t be possible to digitize the geometry of a referencing feature from this widget
- Parameters:
context (QgsAttributeEditorContext) –
- setFeature(self, feature: QgsFeature, update: bool = True)¶
Sets the
feature
being edited and updates the UI unlessupdate
is set toFalse
- Parameters:
feature (QgsFeature) –
update (bool = True) –
- setForceSuppressFormPopup(self, forceSuppressFormPopup: bool)¶
Sets force suppress form popup status with
forceSuppressFormPopup
configured for this widget- Parameters:
forceSuppressFormPopup (bool) –
- setLabel(self, label: str = '')¶
Sets
label
for this element If it’s empty it takes the relation id as label- Parameters:
label (str = '') –
- setMultiEditFeatureIds(self, fids: object)¶
Set multiple feature to edit simultaneously.
- Parameters:
fids (object) – Multiple Id of features to edit
New in version 3.24.
- setNmRelationId(self, nmRelationId: Any = None)¶
Sets
nmRelationId
for the relation id of the second relation involved in an N:M relation. If it’s empty, then it’s considered as a 1:M relationship.- Parameters:
nmRelationId (Any = None) –
- setRelationFeature(self, relation: QgsRelation, feature: QgsFeature)¶
Sets the
relation
and thefeature
- Parameters:
relation (QgsRelation) –
feature (QgsFeature) –
- setRelations(self, relation: QgsRelation, nmrelation: QgsRelation)¶
Sets the relation(s) for this widget If only one relation is set, it will act as a simple 1:N relation widget If both relations are set, it will act as an N:M relation widget inserting and deleting entries on the intermediate table as required.
- Parameters:
relation (QgsRelation) – Relation referencing the edited table
nmrelation (QgsRelation) – Optional reference from the referencing table to a 3rd N:M table
- setShowLabel(self, showLabel: bool)¶
Defines if a title label should be shown for this widget.
Deprecated since version QGIS: 3.20 label is handled directly in
QgsAttributeForm
.- Parameters:
showLabel (bool) –
- setTitle(self, title: str)¶
Sets the title of the widget, if it is wrapped within a
QgsCollapsibleGroupBox
Deprecated since version QGIS: 3.20 label is handled directly in
QgsAttributeForm
.- Parameters:
title (str) –
- showEvent(self, QShowEvent)¶
Refresh the UI when the widget becomes visible
- showLabel(self) bool ¶
Defines if a title label should be shown for this widget.
Deprecated since version QGIS: 3.20 label is handled directly in
QgsAttributeForm
.- Return type:
bool
- tabletEvent(self, QTabletEvent)¶
- timerEvent(self, QTimerEvent)¶
- toggleEditing(self, state: bool)¶
Toggles editing state of the widget
- Parameters:
state (bool) –
- unlinkFeature(self, fid: int = ::QgsFeatureId())¶
Unlinks a feature with given
fid
- Parameters:
fid (int = ::QgsFeatureId()) –
- unlinkFeatures(self, fids: object)¶
Unlinks the features with
fids
- Parameters:
fids (object) –
- updateMicroFocus(self)¶
- updateTitle(self)¶
Updates the title contents to reflect the current state of the widget
Deprecated since version QGIS: 3.20 label is handled directly in
QgsAttributeForm
.
- updateUi(self)¶
A hook called every time the state of the relation editor widget has changed via calling its set* methods or slots, e.g. changed relation, added feature, etc. Should be used to refresh the UI regarding the new data. Check
QgsRealationEditorWidget
as an example.
- wheelEvent(self, QWheelEvent)¶