Class: QgsModelComponentGraphicItem

class qgis.gui.QgsModelComponentGraphicItem

Bases: PyQt5.QtWidgets.QGraphicsObject

Base class for graphic items representing model components in the model designer.

Warning

Not stable API

New in version 3.14.

QgsModelComponentGraphicItem(component: QgsProcessingModelComponent, model: QgsProcessingModelAlgorithm, parent: QGraphicsItem) Constructor for QgsModelComponentGraphicItem for the specified component, with the specified parent item.

The model argument specifies the associated processing model. Ownership of model is not transferred, and it must exist for the lifetime of this object.

Ownership of component is transferred to the item.

Methods

boundingRect

rtype:

QRectF

calculateAutomaticLinkPoint

Returns the best link point to use for a link originating at a specified other item.

canDeleteComponent

Returns True if the component can be deleted.

childEvent

component

Returns the model component associated with this item.

connectNotify

contains

param point:

contextMenuEvent

customEvent

deleteComponent

Called when the component should be deleted.

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

dropEvent

editComment

Called when the comment attached to the item should be edited.

editComponent

Called when the component should be edited.

event

fillColor

Returns the fill color for the item for the specified state.

flags

Returns item flags.

focusInEvent

focusOutEvent

font

Returns the font used to render text in the item.

hoverEnterEvent

param event:

hoverLeaveEvent

param event:

hoverMoveEvent

param event:

iconPicture

Returns a QPicture version of the item's icon, if available.

iconPixmap

Returns a QPixmap version of the item's icon, if available.

inputMethodEvent

inputMethodQuery

isSignalConnected

itemChange

param change:

itemRect

Returns the rectangle representing the body of the item.

keyPressEvent

keyReleaseEvent

label

Returns the item's label text.

linkPoint

Returns the location of the link point with the specified index on the specified edge.

linkPointCount

Returns the number of link points associated with the component on the specified edge.

linkPointText

Returns the text to use for the link point with the specified index on the specified edge.

model

Returns the model associated with this item.

mouseDoubleClickEvent

param event:

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

moveComponentBy

Moves the component by the specified dx and dy.

paint

param painter:

prepareGeometryChange

previewItemMove

Shows a preview of moving the item from its stored position by dx, dy.

receivers

sceneEvent

sceneEventFilter

sender

senderSignalIndex

setFont

Sets the font used to render text in the item.

setItemRect

Sets a new scene rect for the item.

setLabel

Returns the item's label text.

state

Returns the item's current state.

strokeColor

Returns the stroke color for the item for the specified state.

strokeStyle

Returns the stroke style to use while rendering the outline of the item.

textColor

Returns the label text color for the item for the specified state.

timerEvent

titleAlignment

Returns the title alignment

truncatedTextForItem

Truncates a text string so that it fits nicely within the item's width, accounting for margins and interactive buttons.

updateButtonPositions

Updates the item's button positions, based on the current item rect.

updateMicroFocus

updateStoredComponentPosition

Updates the position and size stored in the model for the associated comment

view

Returns the associated view.

wheelEvent

Signals

aboutToChange

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

changed

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

repaintArrows

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

requestModelRepaint

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

sizePositionChanged

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

updateArrowPaths

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

Attributes

Hover

Normal

Selected

Unused

class Flag

Bases: int

class Flags
class Flags(Union[QgsModelComponentGraphicItem.Flags, QgsModelComponentGraphicItem.Flag])
class Flags(QgsModelComponentGraphicItem.Flags)

Bases: sip.wrapper

Hover = 2
Normal = 0
Selected = 1
class State

Bases: int

Unused = 1
aboutToChange

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

boundingRect(self) QRectF
Return type:

QRectF

calculateAutomaticLinkPoint(self, other: QgsModelComponentGraphicItem) Tuple[QPointF, Qt.Edge]

Returns the best link point to use for a link originating at a specified other item.

Parameters:

other (QgsModelComponentGraphicItem) – item at other end of link

Returns:

  • calculated link point in item coordinates.

  • edge: item edge for calculated best link point

calculateAutomaticLinkPoint(self, point: Union[QPointF, QPoint]) -> Tuple[QPointF, Qt.Edge] Returns the best link point to use for a link originating at a specified other point.

Parameters:

other – point for other end of link (in scene coordinates)

Return type:

Tuple[QPointF, Qt.Edge]

Returns:

  • calculated link point in item coordinates.

  • edge: item edge for calculated best link point

canDeleteComponent(self) bool

Returns True if the component can be deleted.

Return type:

bool

changed

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)
component(self) QgsProcessingModelComponent

Returns the model component associated with this item.

Return type:

QgsProcessingModelComponent

connectNotify(self, QMetaMethod)
contains(self, point: QPointF | QPoint) bool
Parameters:

point (Union[QPointF) –

Return type:

bool

contextMenuEvent(self, QGraphicsSceneContextMenuEvent)
customEvent(self, QEvent)
deleteComponent(self)

Called when the component should be deleted.

The default implementation does nothing.

disconnectNotify(self, QMetaMethod)
dragEnterEvent(self, QGraphicsSceneDragDropEvent)
dragLeaveEvent(self, QGraphicsSceneDragDropEvent)
dragMoveEvent(self, QGraphicsSceneDragDropEvent)
dropEvent(self, QGraphicsSceneDragDropEvent)
editComment(self)

Called when the comment attached to the item should be edited.

The default implementation does nothing.

editComponent(self)

Called when the component should be edited.

The default implementation does nothing.

event(self, QEvent) bool
fillColor(self, state: QgsModelComponentGraphicItem.State) QColor

Returns the fill color for the item for the specified state.

Parameters:

state (QgsModelComponentGraphicItem.State) –

Return type:

QColor

flags(self) QgsModelComponentGraphicItem.Flags

Returns item flags.

Return type:

QgsModelComponentGraphicItem.Flags

focusInEvent(self, QFocusEvent)
focusOutEvent(self, QFocusEvent)
font(self) QFont

Returns the font used to render text in the item.

See also

setFont()

Return type:

QFont

hoverEnterEvent(self, event: QGraphicsSceneHoverEvent)
Parameters:

event (QGraphicsSceneHoverEvent) –

hoverLeaveEvent(self, event: QGraphicsSceneHoverEvent)
Parameters:

event (QGraphicsSceneHoverEvent) –

hoverMoveEvent(self, event: QGraphicsSceneHoverEvent)
Parameters:

event (QGraphicsSceneHoverEvent) –

iconPicture(self) QPicture

Returns a QPicture version of the item’s icon, if available.

Return type:

QPicture

iconPixmap(self) QPixmap

Returns a QPixmap version of the item’s icon, if available.

Return type:

QPixmap

inputMethodEvent(self, QInputMethodEvent)
inputMethodQuery(self, Qt.InputMethodQuery) Any
isSignalConnected(self, QMetaMethod) bool
itemChange(self, change: QGraphicsItem.GraphicsItemChange, value: Any) Any
Parameters:
  • change (QGraphicsItem.GraphicsItemChange) –

  • value (Any) –

Return type:

Any

itemRect(self, storedRect: bool = False) QRectF

Returns the rectangle representing the body of the item.

Parameters:

storedRect (bool = False) –

Return type:

QRectF

keyPressEvent(self, QKeyEvent)
keyReleaseEvent(self, QKeyEvent)
label(self) str

Returns the item’s label text.

See also

setLabel()

Return type:

str

linkPoint(self, edge: Qt.Edge, index: int, incoming: bool) QPointF

Returns the location of the link point with the specified index on the specified edge.

Parameters:
  • edge (Qt.Edge) –

  • index (int) –

  • incoming (bool) –

Return type:

QPointF

linkPointCount(self, edge: Qt.Edge) int

Returns the number of link points associated with the component on the specified edge.

Parameters:

edge (Qt.Edge) –

Return type:

int

linkPointText(self, edge: Qt.Edge, index: int) str

Returns the text to use for the link point with the specified index on the specified edge.

Parameters:
  • edge (Qt.Edge) –

  • index (int) –

Return type:

str

model(self) QgsProcessingModelAlgorithm

Returns the model associated with this item.

Return type:

QgsProcessingModelAlgorithm

mouseDoubleClickEvent(self, event: QGraphicsSceneMouseEvent)
Parameters:

event (QGraphicsSceneMouseEvent) –

mouseMoveEvent(self, QGraphicsSceneMouseEvent)
mousePressEvent(self, QGraphicsSceneMouseEvent)
mouseReleaseEvent(self, QGraphicsSceneMouseEvent)
moveComponentBy(self, dx: float, dy: float)

Moves the component by the specified dx and dy.

Warning

Call this method, not QGraphicsItem.moveBy!

Parameters:
  • dx (float) –

  • dy (float) –

paint(self, painter: QPainter, option: QStyleOptionGraphicsItem, widget: QWidget = None)
Parameters:
  • painter (QPainter) –

  • option (QStyleOptionGraphicsItem) –

  • widget (QWidget = None) –

prepareGeometryChange(self)
previewItemMove(self, dx: float, dy: float)

Shows a preview of moving the item from its stored position by dx, dy.

Parameters:
  • dx (float) –

  • dy (float) –

receivers(self, PYQT_SIGNAL) int
repaintArrows

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

requestModelRepaint

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

sceneEvent(self, QEvent) bool
sceneEventFilter(self, QGraphicsItem, QEvent) bool
sender(self) QObject
senderSignalIndex(self) int
setFont(self, font: QFont)

Sets the font used to render text in the item.

See also

font()

Parameters:

font (QFont) –

setItemRect(self, rect: QRectF)

Sets a new scene rect for the item.

Parameters:

rect (QRectF) –

setLabel(self, label: str)

Returns the item’s label text.

See also

label()

Parameters:

label (str) –

sizePositionChanged

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

state(self) QgsModelComponentGraphicItem.State

Returns the item’s current state.

Return type:

QgsModelComponentGraphicItem.State

strokeColor(self, state: QgsModelComponentGraphicItem.State) QColor

Returns the stroke color for the item for the specified state.

Parameters:

state (QgsModelComponentGraphicItem.State) –

Return type:

QColor

strokeStyle(self, state: QgsModelComponentGraphicItem.State) Qt.PenStyle

Returns the stroke style to use while rendering the outline of the item.

Parameters:

state (QgsModelComponentGraphicItem.State) –

Return type:

Qt.PenStyle

textColor(self, state: QgsModelComponentGraphicItem.State) QColor

Returns the label text color for the item for the specified state.

Parameters:

state (QgsModelComponentGraphicItem.State) –

Return type:

QColor

timerEvent(self, QTimerEvent)
titleAlignment(self) Qt.Alignment

Returns the title alignment

Return type:

Qt.Alignment

truncatedTextForItem(self, text: str) str

Truncates a text string so that it fits nicely within the item’s width, accounting for margins and interactive buttons.

Parameters:

text (str) –

Return type:

str

updateArrowPaths

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

updateButtonPositions(self)

Updates the item’s button positions, based on the current item rect.

updateMicroFocus(self)
updateStoredComponentPosition(self, pos: QPointF | QPoint, size: QSizeF)

Updates the position and size stored in the model for the associated comment

Parameters:
  • pos (Union[QPointF) –

  • size (QSizeF) –

view(self) QgsModelGraphicsView

Returns the associated view.

Return type:

QgsModelGraphicsView

wheelEvent(self, QGraphicsSceneWheelEvent)