Class: QgsPlotRubberBand

class qgis.gui.QgsPlotRubberBand

Bases: PyQt5.QtCore.QObject

QgsPlotRubberBand is an abstract base class for temporary rubber band items in various shapes, for use within QgsPlotCanvas widgets.

New in version 3.26.

QgsPlotRubberBand(canvas: QgsPlotCanvas = None) Constructor for QgsPlotRubberBand.

Methods

brush

Returns the brush used for drawing the rubber band.

canvas

Returns the canvas associated with the rubber band.

childEvent

connectNotify

customEvent

disconnectNotify

finish

Called when a rubber band use has finished and the rubber band is no longer required.

isSignalConnected

pen

Returns the pen used for drawing the rubber band.

receivers

sender

senderSignalIndex

setBrush

Sets the brush used for drawing the rubber band.

setPen

Sets the pen used for drawing the rubber band.

start

Called when a rubber band should be created at the specified starting position (in canvas coordinate space).

timerEvent

update

Called when a rubber band should be updated to reflect a temporary ending position (in canvas coordinate space).

updateRect

Calculates an updated bounding box rectangle from a original start position and new position.

brush(self) QBrush

Returns the brush used for drawing the rubber band.

See also

setBrush()

See also

pen()

Return type:

QBrush

canvas(self) QgsPlotCanvas

Returns the canvas associated with the rubber band.

Return type:

QgsPlotCanvas

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
disconnectNotify(self, QMetaMethod)
finish(self, position: QPointF | QPoint = QPointF(), modifiers: Qt.KeyboardModifiers | Qt.KeyboardModifier = Qt.KeyboardModifiers()) QRectF

Called when a rubber band use has finished and the rubber band is no longer required. Returns the final bounding box of the rubber band.

Parameters:
  • position (Union[QPointF) –

  • modifiers (Union[Qt.KeyboardModifiers) –

Return type:

QRectF

isSignalConnected(self, QMetaMethod) bool
pen(self) QPen

Returns the pen used for drawing the rubber band.

See also

setPen()

See also

brush()

Return type:

QPen

receivers(self, PYQT_SIGNAL) int
sender(self) QObject
senderSignalIndex(self) int
setBrush(self, brush: QBrush | QColor | Qt.GlobalColor | QGradient)

Sets the brush used for drawing the rubber band.

See also

brush()

See also

setPen()

Parameters:

brush (Union[QBrush) –

setPen(self, pen: QPen | QColor | Qt.GlobalColor | QGradient)

Sets the pen used for drawing the rubber band.

See also

pen()

See also

setBrush()

Parameters:

pen (Union[QPen) –

start(self, position: QPointF | QPoint, modifiers: Qt.KeyboardModifiers | Qt.KeyboardModifier)

Called when a rubber band should be created at the specified starting position (in canvas coordinate space).

Parameters:
  • position (Union[QPointF) –

  • modifiers (Union[Qt.KeyboardModifiers) –

timerEvent(self, QTimerEvent)
update(self, position: QPointF | QPoint, modifiers: Qt.KeyboardModifiers | Qt.KeyboardModifier)

Called when a rubber band should be updated to reflect a temporary ending position (in canvas coordinate space).

Parameters:
  • position (Union[QPointF) –

  • modifiers (Union[Qt.KeyboardModifiers) –

updateRect(self, start: QPointF | QPoint, position: QPointF | QPoint, constrainSquare: bool, fromCenter: bool) QRectF

Calculates an updated bounding box rectangle from a original start position and new position. If constrainSquare is True then the bounding box will be forced to a square shape. If fromCenter is True then the original start position will form the center point of the returned rectangle.

Parameters:
  • start (Union[QPointF) –

  • position (Union[QPointF) –

  • constrainSquare (bool) –

  • fromCenter (bool) –

Return type:

QRectF