Class: QgsModelComponentGraphicItem

class qgis.gui.QgsModelComponentGraphicItem(component: QgsProcessingModelComponent, model: QgsProcessingModelAlgorithm, parent: QGraphicsItem)

Bases: PyQt5.QtWidgets.QGraphicsObject

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.

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

Warning

Not stable API

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

Emitted when the definition of the associated component is about to be changed by the item.

changed

Emitted when the definition of the associated component is changed by the item.

repaintArrows

Emitted when item requests that all connected arrows are repainted.

requestModelRepaint

Emitted by the item to request a repaint of the parent model scene.

sizePositionChanged

Emitted when the item’s size or position changes.

updateArrowPaths

Emitted when item requires that all connected arrow paths are recalculated.

Attributes

Hover

Normal

Selected

class Flag

Bases: int

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

Bases: sip.wrapper

Hover = 2
Normal = 0
Selected = 1
class State

Bases: int

aboutToChange

Emitted when the definition of the associated component is about to be changed by the item.

The text argument gives the translated text describing the change about to occur, and the optional id can be used to group the associated undo commands. [signal]

Parameters
  • text (str) –

  • id (int = 0) –

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

Emitted when the definition of the associated component is changed by the item. [signal]

childEvent(self, QChildEvent)
component(self)QgsProcessingModelComponent

Returns the model component associated with this item.

Return type

QgsProcessingModelComponent

connectNotify(self, QMetaMethod)
contains(self, point: Union[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

Emitted when item requests that all connected arrows are repainted. [signal]

requestModelRepaint

Emitted by the item to request a repaint of the parent model scene. [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

Emitted when the item’s size or position changes. [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

Emitted when item requires that all connected arrow paths are recalculated. [signal]

updateButtonPositions(self)

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

updateMicroFocus(self)
updateStoredComponentPosition(self, pos: Union[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)