Bug report #13152

QgsRubberBand not displaying holes in geometry

Added by Luca Congedo about 5 years ago. Updated about 5 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:-
Affected QGIS version:2.10.0 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:21215

Description

Adding a geometry from a shapefile to QgsRubberBand does not displays holes in the original geometry (holes are filled).

For testing, try the following code with the attached shapefile.

from qgis.core import *
from qgis.gui import * 
canvas = qgis.utils.iface.mapCanvas()
cLayer = canvas.currentLayer()
rbbrBndPol = QgsRubberBand(canvas, 2)
f = QgsFeature()
fR = QgsFeatureRequest().setFilterFid(0)
f = cLayer.getFeatures(fR)
f = f.next()
rbbrBndPol.addGeometry(f.geometry(), cLayer)

Thank you

SHAPE.zip (5.61 KB) Luca Congedo, 2015-07-24 01:03 PM

History

#1 Updated by Matthias Kuhn about 5 years ago

  • Status changed from Open to Closed

This is by design. The rubberband is the kind of tool you would use to draw a hole into an existing polygon.
You can use QgsHighlight instead.

http://qgis.org/api/classQgsHighlight.html

#2 Updated by Luca Congedo about 5 years ago

Sorry for the noise.
Thank you very much for the link.

Cheers

Also available in: Atom PDF