Due to our requirement, the default "Add Feature" will not work for us. So we decided to create a new GUI which validates and does some calculation before changing a layer. This GUI holds the information in a list and based on some conditions decides which layer/layers to edit.

My add-feature tool needs to be similar to the default one, with default add-feature as soon as you click it starts drawing an arbitrary line on the canvas. Similar to the following picture.

QGIS Map Canvas

How can I represent the information on the QGIS map canvas without adding any new layer?

In short, I want to draw lines/polygons on map canvas. These lines and polygons are totally virtual and after execution of GUI will be removed. Is there a function/class which does this?

1 Answer 1


You need the class QgsRubberBands. Rubber Bands draw temporary objects on the map canvas without adding new layers.

Instructions from pyqgis cookbook

Your Answer

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

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