[Qgis-developer] Change the query of a query layer (postgis)

Olivier Dalang olivier.dalang at gmail.com
Wed Jun 17 07:45:38 PDT 2015


Hi Enrico,

Hmm I didn't think of that, thanks for the idea ! But I can't use it since
I may have several user at once.

Best,

Olivier

2015-06-17 16:03 GMT+02:00 enricofer <enricofer at gmail.com>:

> Hi Olivier,
> In your case, I think that the best way to do this is to create a view
> from the sql query and load it as layer, than, when qslider changes, change
> the view definition with "ALTER VIEW"  and reload the layer.
>
> Regards,
>
> Enrico Ferreguti
>
> Il giorno 17/giu/2015, alle ore 14:29, olivier [via OSGeo.org] <[hidden
> email] <http:///user/SendEmail.jtp?type=node&node=5211452&i=0>> ha
> scritto:
>
> Hi !
>
> Is it possible to change the query of a postgis query layer in python
> without reloading the project ?
>
> The goal is to have a parameter in my query that I'd be able to change
> with a slider.
>
> I tried the QgsVectorLayer.setDataSource() method, but it makes QGis crash.
> I tried the workaround described here (
> http://gis.stackexchange.com/questions/62610/changing-data-source-of-layer-in-qgis
> ), writing and reading the XML file, but it also makes QGis crash.
>
> If not possible, is there a serious limitation behind this, or is the
> feature just missing/bugged ?
>
> Example :
>
> I have this query loaded as a layer:
>
> "SELECT id, name, ST_Buffer(geom,25) as geom FROM my_table"
>
> But I want to be able to change the hardcoded buffer from 25 to some value
> from a QSlider.
>
> Thanks!
>
> Olivier
>
> _______________________________________________
> Qgis-developer mailing list
> [hidden email] <http:///user/SendEmail.jtp?type=node&node=5211424&i=0>
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://osgeo-org.1560.x6.nabble.com/Change-the-query-of-a-query-layer-postgis-tp5211424.html
>  To unsubscribe from Quantum GIS - Developer, click here.
> NAML
> <http://osgeo-org.1560.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
>
> ------------------------------
> View this message in context: Re: Change the query of a query layer
> (postgis)
> <http://osgeo-org.1560.x6.nabble.com/Change-the-query-of-a-query-layer-postgis-tp5211424p5211452.html>
> Sent from the Quantum GIS - Developer mailing list archive
> <http://osgeo-org.1560.x6.nabble.com/Quantum-GIS-Developer-f4099106.html>
> at Nabble.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/20150617/9fde7386/attachment-0001.html>


More information about the Qgis-developer mailing list