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

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[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

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)