[Qgis-developer] setFilterExpression() does not works?
alexander.bruy at gmail.com
Wed Jul 23 08:44:00 PDT 2014
thanks for your reply.
Ticket opened https://hub.qgis.org/issues/10936
2014-07-23 18:28 GMT+03:00 Matthias Kuhn <matthias.kuhn at gmx.ch>:
> 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.
> 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
More information about the Qgis-developer