Class: QgsRelationReferenceWidget

A widget which shows related features.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsRelationReferenceWidget

Base classes

QWidget

QObject

QPaintDevice

Methods

allowAddFeatures

Determines if a button for adding new features should be shown.

allowMapIdentification

determines if the widget offers the possibility to select the related feature on the map (using a dedicated map tool)

chainFilters

Determines if the filters are chained

deleteForeignKeys

unset the currently related feature

embedForm

determines if the form of the related feature will be shown

fetchLimit

Returns the limit of fetched features (0 means all features)

filterExpression

Returns the currently set filter expression.

foreignKey

returns the related feature foreign key

foreignKeys

Returns the related feature foreign keys

init

mapIdentification

activate the map tool to select a new related feature on the map

openForm

open the form of the related feature in a new dialog

openFormButtonVisible

determines the open form button is visible in the widget

orderExpression

Returns the string of the order expression The order expression will be used for sort values in the combobox.

readOnlySelector

determines if the drop-down is enabled

referencedFeature

Returns the related feature (from the referenced layer) if no feature is related, it returns an invalid feature

referencedLayerDataSource

Returns the public data source of the referenced layer

referencedLayerId

Returns the id of the referenced layer

referencedLayerName

Returns the name of the referenced layer

referencedLayerProviderKey

Returns the data provider key of the referenced layer

relation

Returns the current relation, which might be invalid

saveReferencedAttributeForm

Trigger save of the embedded referenced attribute form.

setAllowAddFeatures

Determines if a button for adding new features should be shown.

setAllowMapIdentification

setChainFilters

Set if filters are chained.

setEditorContext

Sets the editor context

setEmbedForm

setFetchLimit

Set the limit of fetched features (0 means all features)

setFilterExpression

If not empty, will be used as filter expression.

setFilterFields

Sets the fields for which filter comboboxes will be created

setForeignKey

this sets the related feature using from the foreign key

setForeignKeys

Sets the related feature using the foreign keys

setFormFeature

Set the current form feature (from the referencing layer)

setOpenFormButtonVisible

setOrderExpression

Set the string of the order expression The order expression will be used for sort values in the combobox.

setParentFormFeature

Set the current parent form feature

setReadOnlySelector

setReferencedLayerDataSource

Set the public data source of the referenced layer to referencedLayerDataSource

setReferencedLayerId

Set the id of the referenced layer to referencedLayerId

setReferencedLayerName

Set the name of the referenced layer to referencedLayerName

setReferencedLayerProviderKey

Set the data provider key of the referenced layer to referencedLayerProviderKey

setRelation

setRelationEditable

setSortOrder

Set the order direction The order direction will be used for sort values in the combobox.

showIndeterminateState

Sets the widget to display in an indeterminate "mixed value" state.

sortOrder

Returns the order direction The order direction will be used for sort values in the combobox.

Signals

foreignKeyChanged

Emitted when the foreign key changed

foreignKeysChanged

Emitted when the foreign keys changed

Attributes

Fixed

Pan

Scale

class qgis.gui.QgsRelationReferenceWidget[source]

Bases: QWidget

class CanvasExtent

Bases: int

Fixed = 0
Pan = 1
Scale = 2
allowAddFeatures(self) bool[source]

Determines if a button for adding new features should be shown.

Return type:

bool

allowMapIdentification(self) bool[source]

determines if the widget offers the possibility to select the related feature on the map (using a dedicated map tool)

Return type:

bool

chainFilters(self) bool[source]

Determines if the filters are chained

Return type:

bool

Returns:

True if filters are chained

deleteForeignKeys(self)[source]

unset the currently related feature

embedForm(self) bool[source]

determines if the form of the related feature will be shown

Return type:

bool

fetchLimit(self) int[source]

Returns the limit of fetched features (0 means all features)

Added in version 3.32.

Return type:

int

filterExpression(self) str[source]

Returns the currently set filter expression.

Return type:

str

foreignKey(self) Any[source]

returns the related feature foreign key

Deprecated since version 3.10.

Return type:

Any

signal foreignKeyChanged[source]

Emitted when the foreign key changed

Deprecated since version 3.10.

foreignKeys(self) List[Any][source]

Returns the related feature foreign keys

Added in version 3.10.

Return type:

List[Any]

signal foreignKeysChanged(keys: List[object])[source]

Emitted when the foreign keys changed

Added in version 3.10.

Parameters:

keys (List[object])

init(self)[source]
mapIdentification(self)[source]

activate the map tool to select a new related feature on the map

openForm(self)[source]

open the form of the related feature in a new dialog

openFormButtonVisible(self) bool[source]

determines the open form button is visible in the widget

Return type:

bool

orderExpression(self) str[source]

Returns the string of the order expression The order expression will be used for sort values in the combobox.

Added in version 4.0.

Return type:

str

readOnlySelector(self) bool[source]

determines if the drop-down is enabled

Return type:

bool

referencedFeature(self) QgsFeature[source]

Returns the related feature (from the referenced layer) if no feature is related, it returns an invalid feature

Return type:

QgsFeature

referencedLayerDataSource(self) str[source]

Returns the public data source of the referenced layer

Added in version 3.12.

Return type:

str

referencedLayerId(self) str[source]

Returns the id of the referenced layer

Added in version 3.12.

Return type:

str

referencedLayerName(self) str[source]

Returns the name of the referenced layer

Added in version 3.12.

Return type:

str

referencedLayerProviderKey(self) str[source]

Returns the data provider key of the referenced layer

Added in version 3.12.

Return type:

str

relation(self) QgsRelation[source]

Returns the current relation, which might be invalid

Added in version 3.10.

Return type:

QgsRelation

saveReferencedAttributeForm(self) bool[source]

Trigger save of the embedded referenced attribute form. Returns True on success or if no embedded form is present.

Added in version 3.42.

Return type:

bool

setAllowAddFeatures(self, allowAddFeatures: bool)[source]

Determines if a button for adding new features should be shown.

Parameters:

allowAddFeatures (bool)

setAllowMapIdentification(self, allowMapIdentification: bool)[source]
Parameters:

allowMapIdentification (bool)

setChainFilters(self, chainFilters: bool)[source]

Set if filters are chained. Chained filters restrict the option of subsequent filters based on the selection of a previous filter.

Parameters:

chainFilters (bool) – If chaining should be enabled

setEditorContext(self, context: QgsAttributeEditorContext, canvas: QgsMapCanvas | None, messageBar: QgsMessageBar | None)[source]

Sets the editor context

Note

if context cadDockWidget is null, it won’t be possible to digitize the geometry of a referenced feature from this widget

Parameters:
setEmbedForm(self, display: bool)[source]
Parameters:

display (bool)

setFetchLimit(self, fetchLimit: int)[source]

Set the limit of fetched features (0 means all features)

Added in version 3.32.

Parameters:

fetchLimit (int)

setFilterExpression(self, filterExpression: str | None)[source]

If not empty, will be used as filter expression. Only if this evaluates to True, the value will be shown.

Parameters:

filterExpression (Optional[str])

setFilterFields(self, filterFields: Iterable[str | None])[source]

Sets the fields for which filter comboboxes will be created

Parameters:

filterFields (Iterable[Optional[str]])

setForeignKey(self, value: Any)[source]

this sets the related feature using from the foreign key

Deprecated since version 3.10: Use setForeignKeys.

Parameters:

value (Any)

setForeignKeys(self, values: Iterable[Any])[source]

Sets the related feature using the foreign keys

Added in version 3.10.

Parameters:

values (Iterable[Any])

setFormFeature(self, formFeature: QgsFeature)[source]

Set the current form feature (from the referencing layer)

Added in version 3.10.

Parameters:

formFeature (QgsFeature)

setOpenFormButtonVisible(self, openFormButtonVisible: bool)[source]
Parameters:

openFormButtonVisible (bool)

setOrderExpression(self, orderExpression: str | None)[source]

Set the string of the order expression The order expression will be used for sort values in the combobox.

Added in version 4.0.

Parameters:

orderExpression (Optional[str])

setParentFormFeature(self, parentFormFeature: QgsFeature)[source]

Set the current parent form feature

Added in version 3.42.2.

Parameters:

parentFormFeature (QgsFeature)

setReadOnlySelector(self, readOnly: bool)[source]
Parameters:

readOnly (bool)

setReferencedLayerDataSource(self, referencedLayerDataSource: str | None)[source]

Set the public data source of the referenced layer to referencedLayerDataSource

Added in version 3.12.

Parameters:

referencedLayerDataSource (Optional[str])

setReferencedLayerId(self, referencedLayerId: str | None)[source]

Set the id of the referenced layer to referencedLayerId

Added in version 3.12.

Parameters:

referencedLayerId (Optional[str])

setReferencedLayerName(self, referencedLayerName: str | None)[source]

Set the name of the referenced layer to referencedLayerName

Added in version 3.12.

Parameters:

referencedLayerName (Optional[str])

setReferencedLayerProviderKey(self, referencedLayerProviderKey: str | None)[source]

Set the data provider key of the referenced layer to referencedLayerProviderKey

Added in version 3.12.

Parameters:

referencedLayerProviderKey (Optional[str])

setRelation(self, relation: QgsRelation, allowNullValue: bool)[source]
Parameters:
setRelationEditable(self, editable: bool)[source]
Parameters:

editable (bool)

setSortOrder(self, sortOrder: Qt.SortOrder)[source]

Set the order direction The order direction will be used for sort values in the combobox. Ascending or descending

Added in version 4.0.

Parameters:

sortOrder (Qt.SortOrder)

showIndeterminateState(self)[source]

Sets the widget to display in an indeterminate “mixed value” state.

sortOrder(self) Qt.SortOrder[source]

Returns the order direction The order direction will be used for sort values in the combobox. Ascending or descending

Added in version 4.0.

Return type:

Qt.SortOrder