3

I have a form designed in QGIS 3.8.1. The form is associated with a layer for inputting data. Many of the fields on the form are only relevant if the first field is equal to True.

Example:

Field 1: Is the location positive for mosquito larvae? True/False

Field 2: What stage are the larvae at? L1, L2, L3, Pupae

I do not want Field 2 to be shown unless the value in Field 1 is equal to True. How can I achieve that the Field 2 is displayed only when Field 1 is equal to True?

  • Hello and welcome to GIS SE. It would help if you provided what you did so far (your code/script) and you could provide some example data, so we can replicate your problem and try to find a solution. – Piskr Aug 21 at 13:05
4

You can achieve this through the Attributes Form in the Layers properties. Choose Drag and drop designer. Drag and drop your attributes from Available Widgets-window into the Form Layout-window.

Set alias and widget type. Here I have chosen checkbox where 1 ("pos_loc") is True and 0 is False for field 1 and value map for field 2 ("stage"). pos_loc parameters stage parameters

Add a tab/container (the green plus). The first time you must choose tab and then afterwards change it to a group (container). Give it a name and click OK.

A new tab is added.

enter image description here

Click on "stage" and drag it into and drop it in "Larvae stage"

enter image description here

Double right-click on Larvae stage and check 'Show as group box' and 'Control visibility by expression' and add the expression "pos_loc"=1 and click OK.

enter image description here

Close layer properties. Activate the layer and start editing. A pop-up window like this appears.

enter image description here

If I check the box (the location is positive), the stage field turns up and I can choose a stage from the drop down list.

enter image description here

  • Awesome. Thank you so much for this! Don't suppose you can answer my other question on how to get my Qfield project off the mobile device and into QGis? – Bid19 Aug 22 at 19:05
  • Glad I could help. I create my project in QGIS, then I use QFieldSync plugin to make it portable, then I copy the project into my tablet, use it and when finished, I copy my project back on the PC. (I use a regular USB-B or -C cabel to connect my tablet to the PC.) Read more on qfield.org/docs/index.html. – 9ls1 Aug 23 at 7:12

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.