1

Is it possible to access data with a qml/html-widget of a other layer?

I want to show specific fields, which are stored in a second layer in some kind of table. I'm unsure where or how to begin.

If it's possible what widget-type would be better suited?

EDIT:
I have a geopackage with one point layer and a non-geom layer (just non-spatial data). The non-geom layer is a history of the point-layer. So when I update the data of the point layer, a trigger defined in the point-layer inserts automatically a history-entry with the former actual data of the point-layer.

Now I want to see in the point-layer (on a second tab) the history of the points in a table. In the history-table is the ID of the point-layer for the reference.

So I want to know, how can I access the history-layer from within an qml/html-widget of the point-layer.

0

1 Answer 1

2

Thanks for the edits. That makes things more clear.

I think you want to start with defining an existing 1-N relationship between your point file and your non-geom based history table in QGIS. You mentioned that there is an key that is connecting both the point data and the non-geom table.

The 1-N relationship between your point data and the non-geom table can be defined under the "project" tab, then -> Relations. Also see: https://docs.qgis.org/2.18/en/docs/user_manual/working_with_vector/attribute_table.html#creating-one-or-many-to-many-relations

enter image description here

I made an example in which I have a county (polygon file), and non-geom table. They are both connect by the "name" column.

enter image description here

I created a 1-N relationship as shown on the first screenshot (defining the county polygon as the parent, table as the child feature, and the name column as key.

After defining the relationship between tables, you should be able to see the relationship in the attribute table of your point layer (or my county file)

enter image description here

Then you should be able to create a form Layout (or QML/HTML Widget, using the related information. See the image above in which I made tab 1 the initial "point"data, and "secondary view" is the non-geom or history table. resulting in the image below:

enter image description here

If you create a QML/HTML widget in the non-geom table, that would also be connected with the point/polygon layer.

2
  • I don't understand how to use the SQL-statement to fill a virtual field? Do you have an example?
    – basto
    Apr 8, 2021 at 13:51
  • Thanks for the edit, I will try to give an example.
    – PGerrits
    Apr 8, 2021 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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