I’m working with QGIS 3.4.3 and Python and I’m looking for a better mechanism in attribute table (vector layer) which tells me which fid and which index of a column I’m currently working with.
For example, double click on a column, please tell me fid and index. Similar to signal setAttributeValueChanged but in my case the response is too late. I need the information before entering a value.
My idea is to create a dialog with possible input values and descriptions.
Currently my mechanism works if the user enters value “?” in a column. I get all input values and descriptions from an external dll. This works fine.
I found out a way which could work. I have created an action "My help" using python code and have made visible it in attribute table. Fid and Index is shown correct.
Now I have two questions:
1) Can I create my action "My help" in python automatically. Currently I did it in QGIS interactively. I need a sample.
2) The action "My help" needs access to my python plugin. I need to call some functions. Is it possible? How? (Ok, problem solved by myself):
fid = [% $id %]
idx = [% @field_index %]
aLayer = qgis.utils.iface.activeLayer()
myhelp_dlg = myhelp.classFactory(qgis.utils.iface)
value = myhelp_dlg.ExampleDialog(aLayer,int(fid),int(idx),None)
aLayer.changeAttributeValue(int(fid), int(idx), str(value) )
myhelp_dlg = None