opengisch / QField

A simplified touch optimized interface for QGIS
http://www.qfield.org
GNU General Public License v2.0
829 stars 226 forks source link

Display svg symbol in an attribute #1821

Closed chanteclair12 closed 3 years ago

chanteclair12 commented 3 years ago

Hello everyone, I have a Qgis/Qfield project with a parent table with points and a simple children's table. Each table has a form and the parent table displays the children form. In the children form, I want when attribute 1 is equal to value "D12" for example, then attribute 2 displays the corresponding svg "D12.svg", contained in an SVG folder at the root of the folder containing the Qgis/QField project.

Reproduction Steps:

  1. Add a point layer and make a form with one tab, to catch poles position in the street.

  2. Add a table with a form with one tab, to describe signs hung on poles. An attribute is used to choose the panel model. A second attribute has an expression (CASE WHEN "attribute 1" = 'D12' THEN 'D12.svg'...END) in the default value section. Here, i have tried to put several differents things in the condition :

    • './SVG/D12.svg'
    • 'SVG/D12.dvg'
    • 'D12.svg' This attribute has the option "Relative path to the project".
  3. Make a relation between these two tables in the Qgis project properties.

  4. Include the simple table form in the point layer form.

  5. Generate the QField project with QFieldSyn plugin.

Expected behavior:

Having the good svg symbol displayed depending the choice made in the first attribute

Observed behavior:

If a point exists from Qgis project, a symbol is displayed but in edit, it doesn't change. With a new point, no symbol displayed.

Screenshots and GIFs QGIS behavior svg_qgis

QField behavior svg_qfield

QField version: 1.8.4 Selma (7b5255 v1.8.4)

nirvn commented 3 years ago

@chanteclair12 , can you share a test project?

chanteclair12 commented 3 years ago

@nirvn, QField offline project can be suitable ?

chanteclair12 commented 3 years ago

I manage to display the right svg file but it is necessary to save the modifications in the form and to consult it again. Not very practical. Do you know if the relationship between the choice in the list and the display can be more dynamic?

nirvn commented 3 years ago

@chanteclair12 , yes, offline project is fine.

chanteclair12 commented 3 years ago

I have attached the project to my post. Thanks for you help.

FORM.zip

signedav commented 3 years ago

Currently, the "live" update of the default value while editing is not possible in the normal mode. If you want to have your form updated during editing, you would need to enable the "Fast editing mode". This mode means, that all your values are stored directly after you changed them - be aware there is no "discard changes" option.

To enable it, go to the settings in QField:

Screenshot_20210521-090739_QField Dev

Edit: I tested your project and with fast editing mode it works for me.

chanteclair12 commented 3 years ago

Thanks for this answer. Have a nice day

chanteclair12 commented 3 years ago

Does it mean that attributes can not be modified after ?

signedav commented 3 years ago

It can be modified after.

Normal mode on editing feature:

Fast editing mode on editing feature:

PS. on creating new feature there is a trashcan icon, this would "delete" the feature in case you don't want to have it in the end...

chanteclair12 commented 3 years ago

Thank you for yours explanations. It's clear now.