1

The manual: https://docs.qgis.org/3.16/en/docs/user_manual/working_with_vector/attribute_table.html#creating-one-or-many-to-many-relations describes how to create a N:M relation and how to use it with a attribute form made with drag and drop designer.

With Qt Designer I am only able to create a form for a 1:N relation using a QgsRelationEditorWidget and set the qgisRelation property accordingly. But how do I use a QgsRelationEditorWidget for a N:M (many to many) relation?

1 Answer 1

1

I found out that creating a form for a N:M (many to many) relation in Qt Designer works in the same way as for a 1:N (one to man) relation:

  1. Add a QgsRelationEditorWidget.
  2. Set the qgisRelation property to the Id of your relation (as seen in QGIS -> Project Properties -> Relations). My fault was that I was using the relation name rather than the Id, which are identical for 1:N relations (if automatically created).
  3. Don't forget to check the option Allow adding new features in the QGIS attribute forms dialogue in your associative table.
1
  • Could you explain a bit more? I've defined 2 N-1 relationships towards the "pivot table" as defined in the manual entry you quote. But I don't know where to set it up as a N:M in QT. It treats it as a 1:N Mar 17, 2022 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.