Class: QgsLayoutViewRubberBand

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

Class Hierarchy

Inheritance diagram of qgis.gui.QgsLayoutViewRubberBand

Base classes

QObject

Subclasses

QgsLayoutViewEllipticalRubberBand

QgsLayoutViewEllipseRubberBand is elliptical rubber band for use within QgsLayoutView widgets.

QgsLayoutViewRectangularRubberBand

QgsLayoutViewRectangularRubberBand is rectangular rubber band for use within QgsLayoutView widgets.

QgsLayoutViewTriangleRubberBand

QgsLayoutViewTriangleRubberBand is triangular rubber band for use within QgsLayoutView widgets.

Methods

brush

Returns the brush used for drawing the rubber band.

create

Creates a new instance of the QgsLayoutViewRubberBand subclass.

finish

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

layout

Returns the layout associated with the rubber band.

pen

Returns the pen used for drawing the rubber band.

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 layout coordinate space).

update

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

updateRect

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

view

Returns the view associated with the rubber band.

Signals

sizeChanged

Emitted when the size of the rubber band is changed.

class qgis.gui.QgsLayoutViewRubberBand[source]

Bases: QObject

__init__(view: QgsLayoutView | None = None)

Constructor for QgsLayoutViewRubberBand.

Parameters:

view (Optional[QgsLayoutView] = None)

brush(self) QBrush[source]

Returns the brush used for drawing the rubber band.

See also

setBrush()

See also

pen()

Return type:

QBrush

create(self, view: QgsLayoutView | None) QgsLayoutViewRubberBand | None[source]

Creates a new instance of the QgsLayoutViewRubberBand subclass.

Parameters:

view (Optional[QgsLayoutView])

Return type:

Optional[QgsLayoutViewRubberBand]

finish(self, position: QPointF | QPoint = QPointF(), modifiers: Qt.KeyboardModifiers | Qt.KeyboardModifier = Qt.KeyboardModifiers()) QRectF[source]

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, QPoint] = QPointF())

  • modifiers (Union[Qt.KeyboardModifiers, Qt.KeyboardModifier] = Qt.KeyboardModifiers())

Return type:

QRectF

layout(self) QgsLayout | None[source]

Returns the layout associated with the rubber band.

See also

view()

Return type:

Optional[QgsLayout]

pen(self) QPen[source]

Returns the pen used for drawing the rubber band.

See also

setPen()

See also

brush()

Return type:

QPen

setBrush(self, brush: QBrush | QColor | Qt.GlobalColor | QGradient)[source]

Sets the brush used for drawing the rubber band.

See also

brush()

See also

setPen()

Parameters:

brush (Union[QBrush, Union[QColor, Qt.GlobalColor], QGradient])

setPen(self, pen: QPen | QColor | Qt.GlobalColor)[source]

Sets the pen used for drawing the rubber band.

See also

pen()

See also

setBrush()

Parameters:

pen (Union[QPen, Union[QColor, Qt.GlobalColor]])

signal sizeChanged(size: str)[source]

Emitted when the size of the rubber band is changed. The size argument gives a translated string describing the new rubber band size, with a format which differs per subclass (e.g. rectangles may describe a size using width and height, while circles may describe a size by radius).

Parameters:

size (str)

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

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

Parameters:
  • position (Union[QPointF, QPoint])

  • modifiers (Union[Qt.KeyboardModifiers, Qt.KeyboardModifier])

update(self, position: QPointF | QPoint, modifiers: Qt.KeyboardModifiers | Qt.KeyboardModifier)[source]

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

Parameters:
  • position (Union[QPointF, QPoint])

  • modifiers (Union[Qt.KeyboardModifiers, Qt.KeyboardModifier])

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

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, QPoint])

  • position (Union[QPointF, QPoint])

  • constrainSquare (bool)

  • fromCenter (bool)

Return type:

QRectF

view(self) QgsLayoutView | None[source]

Returns the view associated with the rubber band.

See also

layout()

Return type:

Optional[QgsLayoutView]