3

I cannot understand what the Value Relation widget of the Fields menu in QGIS actually does.

For example: I have a point layer with some columns (ID, value1...) and a table (so just a dbf file) with other values (ID, valueA,...). If I open the Fields menu of the point layer I can set some options for the selected column: Layer (set to table.dbf), Key column (set to ID) and Value column (set to valueA).

Now, if I create a new point, it appears in the row of the widget column a dropdown menu where I can choose the valueA of the table.dbf. And that's ok.

But, what is the meaning of the Key column?

Does someone have an explanation for that? Am I missing something?

7

Key column is a value, that is saved to the field and replaces previous value. The idea is that each key corresponds to value, that you see in the drop-down menu.

EDIT: Imagine a simple table:

Key | Value
1   | Apple
2   | Pear
3   | Passion fruit

Value relation enables you to select "apple" in a drop-down, but save value "1" (the key) to the field. As you can imagine, this can be very useful in relation DBs, such as PostgreSQL.

  • thanks for your reply... but I still don't get it.. have you an example to share? – matteo Jul 30 '14 at 14:19
  • I added an example - hopefully it's more clear now. – Miloš Kroulík Jul 30 '14 at 14:59
  • Is there an example of how to setup the widget in a custom form? Been looking for an example to setup my form. – Tyler Veinot Sep 12 '16 at 15:58

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.