4

Bit of an open question but....

Is it possible to design a form in qt designer that will be used as a form against a qgis layer but interacts with a different table in postgres/postgis as a lookup table.

For example, I have a postgis layer that i'm editing in qgis to capture the locations of shops. Some of the fields to capture are address, postcode and parish. Could I do a lookup to another postgres/postgis table to enable these fields to auto-populated my shops form field?

Si

  • Do you mean just a attribute table with values that you want to show in a dropdown? – Nathan W Dec 9 '13 at 11:02
  • Yep, thats what im after. – geosmiles Dec 9 '13 at 11:04
5

Sure. The best way to do this is to use the Value Relation widget type.

  1. Load your postgis table as a attribute only layer
  2. Select Value Relation on vector layer and set the layer, key, and value

enter image description here

Key is what is shown to the user and Value is what is stored in the field when selected.

In the past I have also just had a single attribute layer with three columns control, key, value. Then I filter for each control using the expression control = 'CommonName'. This allows you to have a single table for all dropdowns on the form and just update it all in one place.

  • Cheers Nathan, not at my desk the moment but will give it a whirl as soon as I can. Looks like what I'm after :-) – geosmiles Dec 9 '13 at 11:09
  • starting to have a play and I was wondering if it is possible to have a 'search' type lookup and not a dropdown list. My address database has 85k records in it! – geosmiles Dec 9 '13 at 11:33
  • For that I think you might need something a bit more custom. I will update my answer. – Nathan W Dec 9 '13 at 11:34
  • Nathan, do you still plan to update the answer. I also need exactly this functionality. Thnaks – Miloš Kroulík Jan 14 '15 at 14:51

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.