[Qgis-developer] Struggling with iface.openFeatureForm()

Alexandre Neto senhor.neto at gmail.com
Thu Aug 21 04:23:46 PDT 2014


Hello all,

I'm trying to finish a plugin that was initially designed for 1.8.

Our workflow is currently on QGIS 2.2, but we will update in the future, so
I'm doing some test in 2.4 and in master.

My goal is to open the feature form of a temporary feature in a layer, and
keep it's attribute values for future actions.

The code is something like this:

mc = iface.mapCanvas()
> layer = mc.currentLayer()
> temp_feature = QgsFeature()
> attributes = []
>


# getting default values (for primary keys)

provider = layer.dataProvider()
> for j in layer.pendingAllAttributesList():
>     if provider.defaultValue(j):
>         attributes.append(provider.defaultValue(j))
>     else:
>         attributes.append(None)
> temp_feature.setAttributes(attributes)
>

>
iface.openFeatureForm(layer, temp_feature)
>


print temp_feature.attributes()


My "problems" are:

In 2.2, after I edit the feature form and press the OK button, the
temp_feature attributes are updated, but so is the first (already commited)
feature of my layer...weird.

In 2.4, the Feature Form always open in non editng mode, even when the
current layer is editable.

In master (2.5 1b205be), after pressing the feature form ok button, a new
feature is automaticly added to the attribute table, and the temporary
feature attributes are not updated.

I though it might be something to do with *updateFeatureOnly* boolean
value, but setting it to True does not seems to make any difference.

Can anyone of you QGIS developing masters throw some light into my poor
brain?

Thanks,

Alexandre Neto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140821/9cedafdb/attachment.html>


More information about the Qgis-developer mailing list