Bug report #10936
setFilterExpression() does not works
|Affected QGIS version:||2.4.0||Regression?:||No|
|Operating System:||all||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||duplicate|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||19292|
QgsFeatureRequest allows advanced features filtering via setFilterExpression() method. But seems this does not work, at least when using from Python.
Here is code snippet:
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'To reproduce:
- open attached shapefile and make it active
- in Python console execute above code
- no features found
- now try to use same expression with "Select by Expression" tool, it finds one feature as expected.
See also this thread http://lists.osgeo.org/pipermail/qgis-developer/2014-July/033965.html