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

Olivier Dalang olivier.dalang at gmail.com
Wed Jun 17 05:29:49 PDT 2015


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150617/3bc8261e/attachment.html>


More information about the Qgis-developer mailing list