Class: QgsLayoutViewTool

class qgis.gui.QgsLayoutViewTool

Bases: PyQt5.QtCore.QObject

Abstract base class for all layout view tools. Layout view tools are user interactive tools for manipulating and adding items to QgsLayoutView widgets.

QgsLayoutViewTool(view: QgsLayoutView, name: str) Constructor for QgsLayoutViewTool, taking a layout view and tool name as parameters.

Methods

action

Returns the action associated with the tool or None if no action is associated.

activate

Called when tool is set as the currently active layout tool.

childEvent

connectNotify

customEvent

deactivate

Called when tool is deactivated.

disconnectNotify

flags

Returns the current combination of flags set for the tool.

ignoredSnapItems

Returns a list of items which should be ignored while snapping events for this tool.

isClickAndDrag

Returns True if a mouse press/release operation which started at startViewPoint and ended at endViewPoint should be considered a "click and drag".

isSignalConnected

keyPressEvent

Key press event for overriding.

keyReleaseEvent

Key release event for overriding.

layout

Returns the layout associated with the tool.

layoutDoubleClickEvent

Mouse double-click event for overriding.

layoutMoveEvent

Mouse move event for overriding.

layoutPressEvent

Mouse press event for overriding.

layoutReleaseEvent

Mouse release event for overriding.

receivers

sender

senderSignalIndex

setAction

Associates an action with this tool.

setCursor

Sets a user defined cursor for use when the tool is active.

setFlags

Sets the combination of flags that will be used for the tool.

timerEvent

toolName

Returns a user-visible, translated name for the tool.

view

Returns the view associated with the tool.

wheelEvent

Mouse wheel event for overriding.

Signals

activated

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

deactivated

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

itemFocused

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

Attributes

FlagSnaps

class Flag

Bases: int

FlagSnaps = 2
class Flags
class Flags(Union[QgsLayoutViewTool.Flags, QgsLayoutViewTool.Flag])
class Flags(QgsLayoutViewTool.Flags)

Bases: sip.wrapper

action(self) QAction

Returns the action associated with the tool or None if no action is associated.

See also

setAction()

Return type:

QAction

activate(self)

Called when tool is set as the currently active layout tool. Overridden implementations must take care to call the base class implementation.

activated

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
deactivate(self)

Called when tool is deactivated. Overridden implementations must take care to call the base class implementation.

deactivated

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

disconnectNotify(self, QMetaMethod)
flags(self) QgsLayoutViewTool.Flags

Returns the current combination of flags set for the tool.

See also

setFlags()

Return type:

QgsLayoutViewTool.Flags

ignoredSnapItems(self) List[QgsLayoutItem]

Returns a list of items which should be ignored while snapping events for this tool.

Return type:

List[QgsLayoutItem]

isClickAndDrag(self, startViewPoint: QPoint, endViewPoint: QPoint) bool

Returns True if a mouse press/release operation which started at startViewPoint and ended at endViewPoint should be considered a “click and drag”. If False is returned, the operation should be instead treated as just a click on startViewPoint.

Parameters:
  • startViewPoint (QPoint) –

  • endViewPoint (QPoint) –

Return type:

bool

isSignalConnected(self, QMetaMethod) bool
itemFocused

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.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

keyPressEvent(self, event: QKeyEvent)

Key press event for overriding. Default implementation does nothing.

Parameters:

event (QKeyEvent) –

keyReleaseEvent(self, event: QKeyEvent)

Key release event for overriding. Default implementation does nothing.

Parameters:

event (QKeyEvent) –

layout(self) QgsLayout

Returns the layout associated with the tool.

See also

view()

Return type:

QgsLayout

layoutDoubleClickEvent(self, event: QgsLayoutViewMouseEvent)

Mouse double-click event for overriding. Default implementation does nothing.

Parameters:

event (QgsLayoutViewMouseEvent) –

layoutMoveEvent(self, event: QgsLayoutViewMouseEvent)

Mouse move event for overriding. Default implementation does nothing.

Parameters:

event (QgsLayoutViewMouseEvent) –

layoutPressEvent(self, event: QgsLayoutViewMouseEvent)

Mouse press event for overriding. Default implementation does nothing. Note that subclasses must ensure that they correctly handle cases when a layoutPressEvent is called without a corresponding layoutReleaseEvent (e.g. due to tool being changed mid way through a press-release operation).

Parameters:

event (QgsLayoutViewMouseEvent) –

layoutReleaseEvent(self, event: QgsLayoutViewMouseEvent)

Mouse release event for overriding. Default implementation does nothing. Note that subclasses must ensure that they correctly handle cases when a layoutPressEvent is called without a corresponding layoutReleaseEvent (e.g. due to tool being changed mid way through a press-release operation).

Parameters:

event (QgsLayoutViewMouseEvent) –

receivers(self, PYQT_SIGNAL) int
sender(self) QObject
senderSignalIndex(self) int
setAction(self, action: QAction)

Associates an action with this tool. When the setLayoutTool method of QgsLayoutView is called the action’s state will be set to on. Usually this will cause a toolbutton to appear pressed in and the previously used toolbutton to pop out.

See also

action()

Parameters:

action (QAction) –

setCursor(self, cursor: QCursor | Qt.CursorShape)

Sets a user defined cursor for use when the tool is active.

Parameters:

cursor (Union[QCursor) –

setFlags(self, flags: QgsLayoutViewTool.Flags | QgsLayoutViewTool.Flag)

Sets the combination of flags that will be used for the tool.

See also

flags()

Parameters:

flags (Union[QgsLayoutViewTool.Flags) –

timerEvent(self, QTimerEvent)
toolName(self) str

Returns a user-visible, translated name for the tool.

Return type:

str

view(self) QgsLayoutView

Returns the view associated with the tool.

See also

layout()

Return type:

QgsLayoutView

wheelEvent(self, event: QWheelEvent)

Mouse wheel event for overriding. Default implementation does nothing.

Parameters:

event (QWheelEvent) –