0

In my python plugin ,i select features from a vector layer dynamically using a loop and executing : VectorLayer.select(feature.id())

when i start the loop, the selection become very slow because the rendering . can i suspend and reactivate rendering in qgis programatically in python.

4

Without seeing your code this is generally the wrong way to do this. You should use QgsVectorLayer::setSelectedFeatures to select features in one go.

ids = [feature.id() for feature in forselection]
layer.setSelectedFeatures(ids)

or with some long loop:

   ifs = []
   for feature in process:
       ..... #do some other stuff
       ids.append(feature.id())

   layer.setSelectedFeatures(ids)
  • this work in QGis api 1.8 ? – fkili mohamed Dec 10 '13 at 21:51
  • Yes it will. That method has been there for a while. – Nathan W Dec 10 '13 at 21:52
  • Don't forget to mark as accepted. – Nathan W Dec 10 '13 at 23:08

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.