Class: QgsLayoutViewTool¶
Abstract base class for all layout view tools. Layout view tools are
user interactive tools for manipulating and adding items to
QgsLayoutView widgets.
Class Hierarchy¶
Base classes¶
Subclasses¶
Layout view tool for adding items to a layout. |
|
Layout view tool for adding node based items to a layout. |
|
Layout view tool for edit node based items in the layout. |
|
Layout view tool for moving and zooming item content. |
|
Layout view tool for panning the layout. |
|
Layout view tool for selecting items in the layout. |
|
Layout view tool for temporarily panning a layout while a key is depressed. |
|
Layout view tool for zooming into and out of the layout. |
|
Layout view tool for temporarily panning a layout while a mouse button is depressed. |
Methods
Returns the action associated with the tool or |
|
Called when tool is set as the currently active layout tool. |
|
Called when tool is deactivated. |
|
Returns the current combination of flags set for the tool. |
|
Returns a list of items which should be ignored while snapping events for this tool. |
|
Returns |
|
Key press event for overriding. |
|
Key release event for overriding. |
|
Returns the layout associated with the tool. |
|
Mouse double-click event for overriding. |
|
Mouse move event for overriding. |
|
Mouse press event for overriding. |
|
Mouse release event for overriding. |
|
Associates an action with this tool. |
|
Sets a user defined cursor for use when the tool is active. |
|
Sets the combination of flags that will be used for the tool. |
|
Returns a user-visible, translated name for the tool. |
|
Returns the view associated with the tool. |
|
Mouse wheel event for overriding. |
Signals
Emitted when the tool is activated. |
|
Emitted when the tool is deactivated. |
|
Emitted when an item is "focused" by the tool, i.e. it should become the active item and should have its properties displayed in any designer windows. |
Attributes
- class qgis.gui.QgsLayoutViewTool[source]¶
Bases:
QObject- __init__(view: QgsLayoutView | None, name: str | None)
Constructor for QgsLayoutViewTool, taking a layout
viewand toolnameas parameters.- Parameters:
view (Optional[QgsLayoutView])
name (Optional[str])
- class Flag¶
Bases:
int
- FlagSnaps = 2¶
- class Flags¶
- class Flags(f: QgsLayoutViewTool.Flags | QgsLayoutViewTool.Flag)
- class Flags(a0: QgsLayoutViewTool.Flags)
Bases:
object
- action(self) QAction | None[source]¶
Returns the action associated with the tool or
Noneif no action is associated.See also
- Return type:
Optional[QAction]
- activate(self)[source]¶
Called when tool is set as the currently active layout tool. Overridden implementations must take care to call the base class implementation.
- deactivate(self)[source]¶
Called when tool is deactivated. Overridden implementations must take care to call the base class implementation.
- flags(self) QgsLayoutViewTool.Flags[source]¶
Returns the current combination of flags set for the tool.
See also
- Return type:
- 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[source]¶
Returns
Trueif a mouse press/release operation which started atstartViewPointand ended atendViewPointshould be considered a “click and drag”. IfFalseis returned, the operation should be instead treated as just a click onstartViewPoint.- Parameters:
startViewPoint (QPoint)
endViewPoint (QPoint)
- Return type:
bool
- signal itemFocused(item: QgsLayoutItem)[source]¶
Emitted when an
itemis “focused” by the tool, i.e. it should become the active item and should have its properties displayed in any designer windows.- Parameters:
item (QgsLayoutItem)
- keyPressEvent(self, event: QKeyEvent | None)[source]¶
Key press event for overriding. Default implementation does nothing.
- Parameters:
event (Optional[QKeyEvent])
- keyReleaseEvent(self, event: QKeyEvent | None)[source]¶
Key release event for overriding. Default implementation does nothing.
- Parameters:
event (Optional[QKeyEvent])
- layout(self) QgsLayout | None[source]¶
Returns the layout associated with the tool.
See also
- Return type:
Optional[QgsLayout]
- layoutDoubleClickEvent(self, event: QgsLayoutViewMouseEvent | None)[source]¶
Mouse double-click event for overriding. Default implementation does nothing.
- Parameters:
event (Optional[QgsLayoutViewMouseEvent])
- layoutMoveEvent(self, event: QgsLayoutViewMouseEvent | None)[source]¶
Mouse move event for overriding. Default implementation does nothing.
- Parameters:
event (Optional[QgsLayoutViewMouseEvent])
- layoutPressEvent(self, event: QgsLayoutViewMouseEvent | None)[source]¶
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 (Optional[QgsLayoutViewMouseEvent])
- layoutReleaseEvent(self, event: QgsLayoutViewMouseEvent | None)[source]¶
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 (Optional[QgsLayoutViewMouseEvent])
- setAction(self, action: QAction | None)[source]¶
Associates an
actionwith this tool. When the setLayoutTool method ofQgsLayoutViewis 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
- Parameters:
action (Optional[QAction])
- setCursor(self, cursor: QCursor | Qt.CursorShape)[source]¶
Sets a user defined
cursorfor use when the tool is active.- Parameters:
cursor (Union[QCursor, Qt.CursorShape])
- setFlags(self, flags: QgsLayoutViewTool.Flags | QgsLayoutViewTool.Flag)[source]¶
Sets the combination of
flagsthat will be used for the tool.See also
- Parameters:
flags (Union[QgsLayoutViewTool.Flags, QgsLayoutViewTool.Flag])
- view(self) QgsLayoutView | None[source]¶
Returns the view associated with the tool.
See also
- Return type:
Optional[QgsLayoutView]