[GIS] Adding description text to attribute field using attribute table in QGIS

qgisqgis-3

I'm using QGIS 3.0.1 and I would like to add a description text to an attribute field. I already use the alias text but I am interested in to store a more detailed description text for an attribute field like a tooltip or something similar. I know how to define conditional formatting (in qgis and python) but I'm not sure if it is possible to add this "detailed" information.

Should this not be possible, could I use customized signals? I mean, when I press F1 something happens (e.g. I create a pop up with my description).

With respect to my problem, I try to implement my own shortcut function using "QShortcut". This works but now I need the index of the selected field, similar to signal "attributeValueChanged". With this information I could create my own pop up with related description.

Should this not be possible, I would create a dialog including a combo box where the user can select one of the fields of the layer. After that the related description would be displayed.

Best Answer

When you add a new a field from the attribute table, you can add a comment to that field.

enter image description here

You can view the comment in the layer properties...

enter image description here

...and by mousing over the field name in the edit feature form.

enter image description here

Note: There are probably other ways to use the field comment feature, but I couldn't find any documentation. Basically every website has a comment section, so "comment" is useless as a search term.

There's no way to add comment text to an existing field (at least not that I could find, but see the note above). A workaround would be to create a new field with the desired comment. Then fill the new field with values from the old field, and delete the old field.

Tested adding a field with a comment with the following file types:

  • shapefile - comment initially appears in layer properties but disappears after saving the layer edits
  • geopackage - same as shapefile
  • temporary scratch layer - comment persists after saving layer edits (but this type of layer is deleted upon closing the QGIS project)
Related Question