Class RelationUtils
Inherits the following classes: QObject
Public Functions
| Type | Name |
|---|---|
| RelationUtils (QObject * parent=nullptr) |
|
| Q_INVOKABLE QgsPolymorphicRelation | addPolymorphicRelation (QgsProject * project, const QVariantList & referencedLayers, const QgsVectorLayer * referencingLayer, const QVariantMap & fieldPairs, const QString & referencedLayerField, const QString & referencedLayerExpression) |
| Q_INVOKABLE QgsPolymorphicRelation | createPolymorphicRelation (const QVariantList & referencedLayers, const QgsVectorLayer * referencingLayer, const QVariantMap & fieldPairs, const QString & referencedLayerField, const QString & referencedLayerExpression) |
| Q_INVOKABLE QgsRelation | createRelation (const QgsVectorLayer * referencedLayer, const QgsVectorLayer * referencingLayer, const QVariantMap & fieldPairs) |
| Q_INVOKABLE QgsRelation | resolveReferencingRelation (QgsProject * project, QgsVectorLayer * layer, const QString & fieldName, const QString & relationId) |
Public Functions Documentation
function RelationUtils
explicit RelationUtils::RelationUtils (
QObject * parent=nullptr
)
function addPolymorphicRelation
Q_INVOKABLE QgsPolymorphicRelation RelationUtils::addPolymorphicRelation (
QgsProject * project,
const QVariantList & referencedLayers,
const QgsVectorLayer * referencingLayer,
const QVariantMap & fieldPairs,
const QString & referencedLayerField,
const QString & referencedLayerExpression
)
Creates and adds a polymorphic relation to the project. This is a convenience function that creates the relation and adds it to the project's relation manager.
Parameters:
projectThe project to add the relation toreferencedLayersThe list of referenced (parent) layersreferencingLayerThe referencing (child) layerfieldPairsA map where keys are referenced field names and values are referencing field namesreferencedLayerFieldThe field name in the child layer that stores the parent layer namereferencedLayerExpressionThe expression to identify the parent layer name (e.g., "@layer_name")
Returns:
A QgsPolymorphicRelation object
function createPolymorphicRelation
Q_INVOKABLE QgsPolymorphicRelation RelationUtils::createPolymorphicRelation (
const QVariantList & referencedLayers,
const QgsVectorLayer * referencingLayer,
const QVariantMap & fieldPairs,
const QString & referencedLayerField,
const QString & referencedLayerExpression
)
Creates a polymorphic relation between multiple referenced layers and a referencing layer. Note: Layers must be added to the project first
Parameters:
referencedLayersThe list of referenced (parent) layersreferencingLayerThe referencing (child) layerfieldPairsA map where keys are referenced field names and values are referencing field namesreferencedLayerFieldThe field name in the child layer that stores the parent layer namereferencedLayerExpressionThe expression to identify the parent layer name (e.g., "@layer_name")
Returns:
A QgsPolymorphicRelation object
function createRelation
Q_INVOKABLE QgsRelation RelationUtils::createRelation (
const QgsVectorLayer * referencedLayer,
const QgsVectorLayer * referencingLayer,
const QVariantMap & fieldPairs
)
Creates a relation between referenced and referencing layers. Note: Layers must be added to the project first
Parameters:
referencedLayerThe referenced (parent) layerreferencingLayerThe referencing (child) layerfieldPairsA map where keys are referenced field names and values are referencing field names
Returns:
A QgsRelation object
function resolveReferencingRelation
Q_INVOKABLE QgsRelation RelationUtils::resolveReferencingRelation (
QgsProject * project,
QgsVectorLayer * layer,
const QString & fieldName,
const QString & relationId
)
The documentation for this class was generated from the following file src/core/utils/relationutils.h