[Qgis-developer] setFilterExpression() does not works?

Alexander Bruy alexander.bruy at gmail.com
Wed Jul 23 07:16:39 PDT 2014

Hi all,

seems expression filtering of features does not works when used from Python.
Here is my test code for Python console:

layer = iface.mapCanvas().currentLayer()
expr = '"dt" = \'2014-07-05\' AND abs("y" - 3.0) <= 0.000001'
request = QgsFeatureRequest().setFilterExpression(expr)
for f in layer.getFeatures(request):
  print 'found'

This code find no matches in attached shapefile when executed from Python
console, but when I try to use same expression in "Select by Expression" tool it
selects one feature.

Maybe I miss something? Should I open a ticket?

Alexander Bruy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.tar.bz2
Type: application/x-bzip2
Size: 737 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140723/7ab748e4/attachment.bin>

More information about the Qgis-developer mailing list