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.

1 Answer 1


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]

or with some long loop:

   ifs = []
   for feature in process:
       ..... #do some other stuff

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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