1

I have a standalone PyQGis application that is working fine. When I query a vector layer via QgsFeatureRequest class, I would like to instantiate one object and reuse it. But I am not sure how to set- and unset- some flags. For example,

request = QgsFeatureRequest()    
expr = QgsExpression(expr_text)
request.setFilterExpression(expr_text)
if no_geometry:
   request.setFlags(QgsFeatureRequest.NoGeometry)
else:
   # does the following line undo the above 'NoGeometry' setting?
   request.setFlags(QgsFeatureRequest.NoFlags)

if subset_attribute:
   request.setSubsetOfAttributes([ind])
else:
   # here, what should I do to undo the above 'setSubsetOfAttributes'???

I guess the bigger question is whether I should keep creating new implicit QgsFeatureRequest objects when query or should I keep one instance and change its flags as above, which way is better?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.