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

New in version 3.14.

Parameters
class Flag

Bases: int

class Flags

Bases: sip.wrapper

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

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

Returns the model component associated with this item.

Return type

QgsProcessingModelComponent

connectNotify()
contains(self, point: Union[QPointF, QPoint]) → bool
Parameters

point (Union[QPointF) –

Return type

bool

contextMenuEvent()
customEvent()
deleteComponent(self)

Called when the component should be deleted.

The default implementation does nothing.

disconnectNotify()
dragEnterEvent()
dragLeaveEvent()
dragMoveEvent()
dropEvent()
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()
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()
focusOutEvent()
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()
inputMethodQuery()
isSignalConnected()
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()
keyReleaseEvent()
label(self) → str

Returns the item’s label text.

See also

setLabel()

Return type

str

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

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

Parameters
  • edge (Qt.Edge) –

  • index (int) –

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()
mousePressEvent()
mouseReleaseEvent()
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()
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()
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()
sceneEventFilter()
sender()
senderSignalIndex()
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()
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()
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()