Thanks Martin<br><br>Bernhard - I don't think your problem is unique - I have also been trying to do the same thing and spent a long time looking through the docs (particularly the API for QgsVectorLayer) to find the solution. I think one problem is that I was looking for something like "Query" as in the qgis layer, but it is named differently in the docs. <br><br>Now I am looking to make a layer invisible (i.e. click the cross next to the layer in qgis, but keep the layer). Again I am finding it difficult - maybe set in the MapCanvas or Registry?<br><br>Ian<br><br>&gt; Dear Martin,<br>&gt; <br>&gt; yes that works. I must have been blindfold, thanks for pointing <br>&gt; it out to me!<br>&gt; <br>&gt; Bernhard<br>&gt; <br>&gt; Am 02.05.2012 23:11, schrieb Martin Dobias:<br>&gt; &gt;On Mon, Apr 30, 2012 at 1:10 PM, Bernhard Ströbl<br>&gt; &gt;&lt;bernhard.stroebl@jena.de&gt;&nbsp; wrote:<br>&gt; &gt;&gt;Hi list,<br>&gt; &gt;&gt;<br>&gt; &gt;&gt;I am trying to change the query of an already loaded PostGIS <br>&gt; layer from<br>&gt; &gt;&gt;within a plugin. Same as if I right-clicked on the layer, <br>&gt; chose "Query..."<br>&gt; &gt;&gt;and entered a WHERE clause there.<br>&gt; &gt;<br>&gt; &gt;That should be as simple as:<br>&gt; &gt;&gt;&gt;&gt;vlayer.setSubsetString("category = 3")<br>&gt; &gt;<br>&gt; &gt;Martin<br>&gt; <br>&gt; <br>&gt; <br>&gt; ________ Information from NOD32 ________<br>&gt; This message was checked by NOD32 Antivirus System for Linux <br>&gt; Mail Server.<br>&gt; http://www.nod32.com<br>&gt; _______________________________________________<br>&gt; Qgis-developer mailing list<br>&gt; Qgis-developer@lists.osgeo.org<br>&gt; http://lists.osgeo.org/mailman/listinfo/qgis-developer