SIGNAL to know when a feature is added to vector layer using PyQGIS

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

SIGNAL to know when a feature is added to vector layer using PyQGIS

Germán Carrillo-2
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


_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: SIGNAL to know when a feature is added to vector layer using PyQGIS

Matthias Kuhn 🌍
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
> [hidden email]
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: SIGNAL to know when a feature is added to vector layer using PyQGIS

Germán Carrillo-2
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 <[hidden email]>:
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
> [hidden email]
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
_______________________________________________
Qgis-developer mailing list
[hidden email]
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


_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer