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.

enter image description here

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

  • What's the exact question? What have you tried and where are you stuck? – DirkB. Jan 10 at 11:47
  • As an option I want to set a value of a column via own dialog box. To do it via double click or shortcut on selected column would be great. Example: i.imgur.com/bupL7B6.png - Currently it works if I enter "?" or an invalid value. I dont want to enter a value first to get my dialog... – DG85 Jan 10 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.