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

Alexandre Neto senhor.neto at gmail.com
Thu Aug 21 04:41:47 PDT 2014


Hi Bernhard,

Thanks for the link, I guess that the 2.4 problem was already identified
and corrected in master.

A bit of update on this matter. Regarding 2.2. I was doing my tests with a
dbf layer. With a postgis table is working well. So I can work with that
for now.

Still, it seems that there is something to fix in 2.5. should I open a
ticket?

Alexandre Neto


On Thu, Aug 21, 2014 at 12:37 PM, Bernhard Ströbl <bernhard.stroebl at jena.de>
wrote:

> 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
>
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140821/c7f0fd8f/attachment.html>


More information about the Qgis-developer mailing list