<meta http-equiv="content-type" content="text/html; charset=utf-8"><div>Hi Olivier,</div><div>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, <span style="background-color:rgba(255,255,255,0)">when qslider changes, </span>change the view definition with "ALTER VIEW"  and reload the layer.</div><div><br></div><div>Regards,</div><div><br></div><div>Enrico Ferreguti<br></div><div><br>Il giorno 17/giu/2015, alle ore 14:29, olivier [via <a href="http://OSGeo.org" target="_top" rel="nofollow" link="external">OSGeo.org</a>] <<a href="/user/SendEmail.jtp?type=node&node=5211452&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>> ha scritto:<br><br></div><blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' type="cite"><div>

        <p dir="ltr">Hi !</p>
<p dir="ltr">Is it possible to change the query of a postgis query layer in python without reloading the project ?</p>
<p dir="ltr">The goal is to have a parameter in my query that I'd be able to change with a slider.</p>
<p dir="ltr">I tried the QgsVectorLayer.setDataSource() method, but it makes QGis crash.<br>
I tried the workaround described here (<a href="http://gis.stackexchange.com/questions/62610/changing-data-source-of-layer-in-qgis" target="_top" rel="nofollow" link="external"> http://gis.stackexchange.com/questions/62610/changing-data-source-of-layer-in-qgis</a> ), writing and reading the XML file, but it also makes QGis crash.</p>
<p dir="ltr">If not possible, is there a serious limitation behind this, or is the feature just missing/bugged ?<br><br></p>
<p dir="ltr">Example :</p>
<p dir="ltr">I have this query loaded as a layer:</p>
<p dir="ltr">"SELECT id, name, ST_Buffer(geom,25) as geom FROM my_table"</p>
<p dir="ltr">But I want to be able to change the hardcoded buffer from 25 to some value from a QSlider.<br><br></p>
<p dir="ltr">Thanks!</p>
<p dir="ltr">Olivier </p>
<br>_______________________________________________
<br>Qgis-developer mailing list
<br><a href="/user/SendEmail.jtp?type=node&node=5211424&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>
<br><a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_top" rel="nofollow" link="external">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a>

        
        
        
        <br>
        <br>
        <hr noshade size="1" color="#cccccc">
        <div style="color:#444;font:12px tahoma,geneva,helvetica,arial,sans-serif">
                <div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
                <a href="http://osgeo-org.1560.x6.nabble.com/Change-the-query-of-a-query-layer-postgis-tp5211424.html" target="_top" rel="nofollow" link="external">http://osgeo-org.1560.x6.nabble.com/Change-the-query-of-a-query-layer-postgis-tp5211424.html</a>
        </div>
        <div style="color:#666;font:11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
                
                To unsubscribe from Quantum GIS - Developer, <a href="" target="_top" rel="nofollow" link="external">click here</a>.<br>
                <a href="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" rel="nofollow" style="font:9px serif" target="_top" link="external">NAML</a>
        </div></div></blockquote>


        
        
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://osgeo-org.1560.x6.nabble.com/Change-the-query-of-a-query-layer-postgis-tp5211424p5211452.html">Re: Change the query of a query layer (postgis)</a><br/>
Sent from the <a href="http://osgeo-org.1560.x6.nabble.com/Quantum-GIS-Developer-f4099106.html">Quantum GIS - Developer mailing list archive</a> at Nabble.com.<br/>