4

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.

2

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)
  • I tried the same but could it be that the comment function does not work for vector layers? I added the comment like you did but I don't see the comment in the attribute table layout. After reloading my shape file, my comment does not exist. The shape file was saved before. Take a look at my screenshot: i.imgur.com/PyISEOK.png – DG85 Apr 10 '18 at 7:31
  • I tested this first only on a temporary scratch layer. After testing on shapefile and geopackage, I see that the comments aren't saved. So, this doesn't solve your problem. Sorry. :( – csk Apr 10 '18 at 14:43
  • At least thank you for your efforts. :) Now I'm using a QInputDialog and I am satisfied with the solution. – DG85 Apr 11 '18 at 8:07

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.