[Qgis-user] 1-Many relation with spatial child layer

Thomas Colley it087 at neath-porttalbot.gov.uk
Sun Apr 10 00:12:45 PDT 2016


Just an update with some progress in case anyone needs this in the future:

I have managed to add buttons (zoom to feature and add feature) to my parent form by passing the selected ids from the child features.

childFormWidget = parentForm.findChildren(QgsRelationEditorWidget)[0]
childForm = childFormWidget .findChildren(QgsRelationEditorWidget)[0]
featureManager = childForm .featureSelectionManager()
infraManager.selectionChanged.connect(changeSelection)

def changeSelection(deselected, selected):
#             set whatever you need to using the selected featureids.

This isn't ideal as I've got buttons on the main form relating to the child records. Ideally I'd love to be able to have those buttons as part of the QgsRelationEditor toolbar but I think that probably means going into the QGIS source and that's beyond me.

Thanks

Tom

From: Thomas Colley
Sent: 20 March 2016 11:47
To: qgis-user at lists.osgeo.org
Subject: 1-Many relation with spatial child layer

Hi

I have used the excellent QGIS relations to set up a custom form on a road layer (parent, lines) and defects (child, points).

Is there any way to access spatial tools for the child record. For example, I would love to have a zoom to feature button for the child record and instead of the plus button to add a new record (attributes only) I would like to have a button to capture a new point on the child layer.

Failing that, is there a method in Python to access the current child record? I have had to add the child form as a standard widget in QT designer as it crashes whenever I try and add the custom QgsRelationReference widget. If I could access the attributes/geom of the child record from the main form I could create the buttons I need.

Thanks in advance for any guidance!

Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20160410/b606eafe/attachment.html>


More information about the Qgis-user mailing list