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: [email protected]
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
_______________________________________________
Qgis-user mailing list
[email protected]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to