Hi QField power users,
the possible project I described in Inspection of 200 Underground Chambers – Feasibility Question - Ask the Community - QField community will likely require the creation of a large number of repetitive forms. Since many fields are structurally identical, I would prefer not to create the forms manually.
In addition, there may be a UX/UI decision during the initial field testing that requires many elements to be modified.
The idea is to generate the forms via PyQGIS, with one code snippet per content type that I instantiate in a loop as often as needed.
Reading How to use QField without QGIS - Ask the Community - QField community indicates that PyQGIS is a reasonable option.
→ Is this a common approach? Are there any examples or pitfalls?
A possible script architecture could be as follows:
| Script | Responsibility |
|---|---|
01_layer_structure.py |
Creates the GeoPackage layers, fields, relations, and constraints |
02_tabs_visibility.py |
Builds the tab layout (QgsAttributeEditorContainer) and sets expression-based visibility per structure type |
03_build_form.py |
Orchestrator — calls element scripts in a loop to populate each tab |
03a_photo_element.py |
Configures one ExternalResource widget block (2 mandatory + relation editor for extras) |
03b_rating_buttons.py |
Configures one ValueMap widget (green / yellow / red) |
03c_comment_field.py |
Configures one TextEdit widget (multiline) |