[Qgis-developer] R: Re: How to get feature frome deleted feature?

Enrico Fiore enricofiore at libero.it
Tue May 19 08:29:02 PDT 2015


Hi Jürgen,

your solution works.

Thank you

Enrico


>----Messaggio originale----
>Da: jef at norbit.de
>Data: 19/05/2015 16.08
>A: <qgis-developer at lists.osgeo.org>
>Ogg: Re: [Qgis-developer] How to get feature frome deleted feature?
>
>Hi Enrico,
>
>On Tue, 19. May 2015 at 14:38:35 +0200, Enrico Fiore wrote:
>> layer.committedFeaturesRemoved.connect(ConfirmTratDeleted)
>> 
>> def ConfirmTratDeleted(layer,fids):
>>         for fid in fids:
>>             iter = layer.getFeatures(QgsFeatureRequest().setFilterFid(fid))
>>             feat = iter.next()
>>             geometry = feat.geometry()
>> 
>> but it returned thi error:
>> 
>>     An error has occured while executing Python code:
>> 
>>     Traceback (most recent call last):
>>      File "", line 234, in ConfirmTratDeleted
>>      StopIteration
>> 
>> I suppose because the features are committed and don't exist anymore.
>> 
>> Somebody can help me to understand how to get features that were deleted?
>
>committedFeaturesRemoved notifies you that the feature were actually removed 
-
>so they don't exists anymore.  But you can use the featureDeleted signal
>that provides a feature id of a (to be) deleted feature and use that
>to fetch it from the provider (layer.dataProvider().getFeatures...)
>
>If you actually need the features after the are actually deleted, you can
>store them in the featureDeleted slot and use the saved copy to in your
>committedFeaturesRemoved slot.
>
>
>
>Jürgen
>
>-- 
>Jürgen E. Fischer           norBIT GmbH             Tel. +49-4931-918175-31
>Dipl.-Inf. (FH)             Rheinstraße 13          Fax. +49-4931-918175-50
>Software Engineer           D-26506 Norden             http://www.norbit.de
>QGIS release manager (PSC)  Germany                    IRC: jef on 
FreeNode                         
>_______________________________________________
>Qgis-developer mailing list
>Qgis-developer at lists.osgeo.org
>http://lists.osgeo.org/mailman/listinfo/qgis-developer




More information about the Qgis-developer mailing list