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

Bernhard Ströbl bernhard.stroebl at jena.de
Thu Aug 21 04:37:25 PDT 2014


Hi Alexandre,

see: http://hub.qgis.org/issues/10865

regards

Bernhard

Am 21.08.2014 13:23, schrieb Alexandre Neto:
> 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
>
>
> _______________________________________________
>


__________ Information from ESET Mail Security, version of virus signature database 10290 (20140821) __________

The message was checked by ESET Mail Security.
http://www.eset.com




More information about the Qgis-developer mailing list