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

Matthias Kuhn matthias.kuhn at gmx.ch
Wed Jul 23 08:28:57 PDT 2014


Hi Alexander,

This seems to be related to the copy constructor of QgsExpression not
working properly. Please file a bug for this.

It's a quite complex topic, because the original expression string
cannot just be used because of dynamically created expressions. On the
other hand the dynamic method fails for certain types (longlong I think).

And personally I think that QgsExpressions could be implicitly shared,
but I've heard other opinions on this topic.

Cheers,
Matthias

On 23.07.2014 16:16, Alexander Bruy wrote:
> 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?
>
>
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer



More information about the Qgis-developer mailing list