1

I have created my custom form for features editing, using layer.setEditForm("form.ui") and layer.setEditFormInit("init") properties. init method receives dialog, layerId and featId as arguments. Everything works ok, but now I need to get a geometry of a new feature before closing the form.

Is there any way to do it?

Feature id gets assigned to "0" and looks like doesn't exist in the features list before accepting changes.

1 Answer 1

2

This is a bug in 1.8 due to 0 being a valid id for an existing feature so you can never get the new uncommited feature. There was a bug report opened in and I fixed it a little while ago.

In the latest dev build (soon 2.0) you are given the full object rather then just the id:

def open(dialog, layer, feature):
    geom = feature.geometry()

So the only really option to have it work is to run a later build.

5
  • Hi Nathan, thanks for your prompt response. I will try with the latest version then. Do you have any prediction on 2.0 release? I know there is a discussion around it, but maybe you have some fresh updates.
    – AlexSV
    Commented Feb 28, 2013 at 9:30
  • Meanwhile, does it mean that if I create a couple of new features, it still won't possible to extract them somehow from the layer afterwards, but before calling save on the layer?
    – AlexSV
    Commented Feb 28, 2013 at 17:54
  • Looks like layer.setEditForm("form.ui") doesn't work anymore with the latest buid (1.9.0 b5dc778). I also can't find UI Edit form setting on the layer's properties in QGIS.
    – AlexSV
    Commented Mar 1, 2013 at 8:29
  • I'll have a look into it. The UI form settings are now on the Fields tab and you have to change the dropdown at the top left.
    – Nathan W
    Commented Mar 1, 2013 at 10:12
  • Thanks, found it. Yes, I guess it is a bug. If after assigning editForm in the code I go to the layer's properties (Fields) and select Attribute editor layout = Provide ui-file I can see a correct path to the UI form. If I click OK now, to save settings and try to add new features, my form pops up as it was before.
    – AlexSV
    Commented Mar 1, 2013 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.