Feature request #15755

Make it simpler to use QgsGeometryRubberBand

Added by Casper Børgesen about 7 years ago. Updated about 6 years ago.

Pull Request or Patch supplied:No Resolution:
Easy fix?:No Copied to github as #:23677


Having previously used the QgsRubberBand to draw temporary lines in QGIS I needed to draw polygons too. I found the QgsGeometryRubberBand which seems to handle polygons much better. After struggeling with the setGeometry(...) method I finally understood how to use it.

QgsRubberBand.setToGeometry method takes a QgsGeometry and extracts all the points into its own container.

QgsGeometryRubberBand.setGeometry method takes an QgsAbstractGeometryV2 and just make a reference to it (takes ownership???).

In use:

geometry = QgsGeometry.fromWkt('SOME GEOMETRY HERE.')
rb = QgsRubberBand(canvas)
rb.setToGeometry(geometry, None)

grb = QgsGeometryRubberBand(canvas)

I had to clone the abstract geometry since I don't keep my geometry object alive.

There two methods have their cousins, the QgsVertexMarker and the QgsHighlight.

Wouldn't it be better to make them all a bit more homogeneous if they are to remain as 4 different classes?


#1 Updated by Giovanni Manghi over 6 years ago

  • Easy fix? set to No

#2 Updated by Jürgen Fischer about 6 years ago

  • Category set to Unknown

Also available in: Atom PDF