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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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