[Qgis-developer] SIGNAL to know when a feature is added to vector layer using PyQGIS

Germán Carrillo carrillo.german at gmail.com
Fri Jun 10 07:53:23 PDT 2016


Hi Matthias,

thanks for the response.

I'm writing a plugin and would like to be notified when vector layers get
new features. As a SIGNAL from dataProvider.addFeatures doesn't exist, the
plugin won't be able to handled such case. I could just suggest people to
avoid writing directly to the provider if they want the plugin to work as
expected, but I think QGIS could notify on those situations.

Do you think a (future) Pull Request is worth for handling this or better
avoid dealing with the provider directly?

Regards,

Germán

2016-06-10 1:43 GMT-05:00 Matthias Kuhn <matthias at opengis.ch>:

> Hi Germán,
>
> I don't think there's a signal to do that.
>
> Is there a reason you have to write the the dataprovider directly rather
> then using the layer's methods?
> If you are in control of the code writing to the dataprovider and the
> code that should react to this, you could also produce the signalling on
> your side.
>
> Matthias
>
> On 06/09/2016 11:24 PM, Germán Carrillo wrote:
> > Hi,
> >
> > I'd like to ask you whether you know any way of being notified when a
> > feature is being added to a vector layer without opening and closing an
> > edit session, e.g., by using:
> >
> > myLayer.dataProvider().addFeatures( [feature] )
> >
> > Which directly writes the new feature to the provider.
> >
> > When working with an edit session I can use featureAdded SIGNAL, which
> > gives me the feature id, but still haven't found a way of using such
> > SIGNAL with no edit session involved.
> >
> > Regards,
> >
> > Germán
> >
> > --
> > -----------
> >    |\__
> > (:>__)(
> >    |/
> > Soluciones Geoinformáticas Libres
> > http://geotux.tuxfamily.org/
> > http://twitter.com/GeoTux2
> > http://about.me/germancarrillo
> >
> > <http://gis.stackexchange.com/users/4972/germ%c3%a1n-carrillo>
> >
> >
> > _______________________________________________
> > Qgis-developer mailing list
> > Qgis-developer at lists.osgeo.org
> > List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> > Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> >
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer




-- 
-----------
   |\__
(:>__)(
   |/
Soluciones Geoinformáticas Libres
http://geotux.tuxfamily.org/
http://twitter.com/GeoTux2
http://about.me/germancarrillo

<http://gis.stackexchange.com/users/4972/germ%c3%a1n-carrillo>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160610/741fbce2/attachment.html>


More information about the Qgis-developer mailing list