Class: QgsLayoutRuler

A custom ruler widget for use with QgsLayoutView, displaying the current zoom and position of the visible layout and for interacting with guides in a layout.

QgsLayoutRuler

QgsLayoutRuler

Class Hierarchy

Inheritance diagram of qgis.gui.QgsLayoutRuler

Base classes

QWidget

QObject

QPaintDevice

Methods

layoutView

Returns the current layout view associated with the ruler.

rulerSize

Returns the ruler size (either the height of a horizontal ruler or the width of a vertical rule).

setContextMenu

Sets a context menu to show when right clicking occurs on the ruler.

setCursorPosition

Updates the position of the marker showing the current mouse position within the view.

setLayoutView

Sets the current layout view to synchronize the ruler with.

setSceneTransform

Sets the current scene transform.

Signals

cursorPosChanged

Emitted when mouse cursor coordinates change

class qgis.gui.QgsLayoutRuler[source]

Bases: QWidget

__init__(parent: QWidget | None = None, orientation: Qt.Orientation = Qt.Horizontal)

Constructor for QgsLayoutRuler, with the specified parent widget and orientation.

Parameters:
  • parent (Optional[QWidget] = None)

  • orientation (Qt.Orientation = Qt.Horizontal)

signal cursorPosChanged(position: QPointF)[source]

Emitted when mouse cursor coordinates change

Parameters:

position (QPointF)

layoutView(self) QgsLayoutView | None[source]

Returns the current layout view associated with the ruler.

See also

setLayoutView()

Return type:

Optional[QgsLayoutView]

rulerSize(self) int[source]

Returns the ruler size (either the height of a horizontal ruler or the width of a vertical rule).

Return type:

int

setContextMenu(self, menu: QMenu | None)[source]

Sets a context menu to show when right clicking occurs on the ruler. Ownership of menu is unchanged.

Parameters:

menu (Optional[QMenu])

setCursorPosition(self, position: QPointF | QPoint)[source]

Updates the position of the marker showing the current mouse position within the view. position is in layout coordinates.

Parameters:

position (Union[QPointF, QPoint])

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

Sets the current layout view to synchronize the ruler with.

See also

layoutView()

Parameters:

view (Optional[QgsLayoutView])

setSceneTransform(self, transform: QTransform)[source]

Sets the current scene transform. This is usually the transform set for a view showing the associated scene, in order to synchronize the view’s display of the scene with the rulers.

Parameters:

transform (QTransform)