Class: QgsModelGraphicsScene

class qgis.gui.QgsModelGraphicsScene

Bases: PyQt5.QtWidgets.QGraphicsScene

QGraphicsScene subclass representing the model designer.

Warning

Not stable API

Added in version 3.14.

QgsModelGraphicsScene(parent: Optional[QObject] = None) Constructor for QgsModelGraphicsScene with the specified parent object.

Methods

childEvent

componentItemAt

Returns the topmost component item at a specified position.

connectNotify

contextMenuEvent

createChildAlgGraphicItem

Creates a new graphic item for a model child algorithm.

createCommentGraphicItem

Creates a new graphic item for a model comment.

createGroupBoxGraphicItem

Creates a new graphic item for a model group box.

createItems

Populates the scene by creating items representing the specified model.

createOutputGraphicItem

Creates a new graphic item for a model output.

createParameterGraphicItem

Creates a new graphic item for a model parameter.

customEvent

deselectAll

Clears any selected items in the scene.

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

drawBackground

drawForeground

dropEvent

event

eventFilter

flags

Returns the current combination of flags set for the scene.

focusInEvent

focusNextPrevChild

focusOutEvent

groupBoxItem

Returns the graphic item corresponding to the specified group box uuid.

helpEvent

inputMethodEvent

isSignalConnected

keyPressEvent

keyReleaseEvent

messageBar

Returns the message bar associated with the scene.

model

rtype:

Optional[QgsProcessingModelAlgorithm]

mouseDoubleClickEvent

mouseMoveEvent

mousePressEvent

param event:

mouseReleaseEvent

receivers

selectAll

Selects all the components in the scene.

selectedComponentItems

Returns list of selected component items.

sender

senderSignalIndex

setFlag

Enables or disables a particular flag for the scene.

setFlags

Sets the combination of flags controlling how the scene is rendered and behaves.

setLastRunResult

Sets the result of the last run of the model through the designer window.

setMessageBar

Sets the message bar associated with the scene.

setModel

param model:

setSelectedItem

Clears any selected items and sets item as the current selection.

showWarning

Shows a warning message, allowing users to click a button to see the full details (longMessage).

timerEvent

wheelEvent

Signals

componentAboutToChange

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

componentChanged

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

rebuildRequired

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

runFromChild

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

runSelected

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

selectedItemChanged

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

showChildAlgorithmLog

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

showChildAlgorithmOutputs

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

Attributes

ArrowLink

FlagHideComments

FlagHideControls

GroupBox

ModelComponent

MouseHandles

RubberBand

ZSnapIndicator

class Flag

Bases: int

FlagHideComments = 4
FlagHideControls = 2
class Flags
class Flags(f: QgsModelGraphicsScene.Flags | QgsModelGraphicsScene.Flag)
class Flags(a0: QgsModelGraphicsScene.Flags)

Bases: sip.wrapper

GroupBox = 0
ModelComponent = 2
MouseHandles = 99
RubberBand = 100
ZSnapIndicator = 101
class ZValues

Bases: int

childEvent(self, a0: QChildEvent | None)
componentAboutToChange

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

componentChanged

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

componentItemAt(self, position: QPointF | QPoint) QgsModelComponentGraphicItem | None

Returns the topmost component item at a specified position.

Parameters:

position (Union[QPointF)

Return type:

Optional[QgsModelComponentGraphicItem]

connectNotify(self, signal: QMetaMethod)
contextMenuEvent(self, event: QGraphicsSceneContextMenuEvent | None)
createChildAlgGraphicItem(self, model: QgsProcessingModelAlgorithm | None, child: QgsProcessingModelChildAlgorithm | None) QgsModelChildAlgorithmGraphicItem | None

Creates a new graphic item for a model child algorithm.

Parameters:
Return type:

Optional[QgsModelChildAlgorithmGraphicItem]

createCommentGraphicItem(self, model: QgsProcessingModelAlgorithm | None, comment: QgsProcessingModelComment | None, parentItem: QgsModelComponentGraphicItem | None) QgsModelComponentGraphicItem | None

Creates a new graphic item for a model comment.

Parameters:
Return type:

Optional[QgsModelComponentGraphicItem]

createGroupBoxGraphicItem(self, model: QgsProcessingModelAlgorithm | None, box: QgsProcessingModelGroupBox | None) QgsModelComponentGraphicItem | None

Creates a new graphic item for a model group box.

Parameters:
Return type:

Optional[QgsModelComponentGraphicItem]

createItems(self, model: QgsProcessingModelAlgorithm | None, context: QgsProcessingContext)

Populates the scene by creating items representing the specified model.

Parameters:
createOutputGraphicItem(self, model: QgsProcessingModelAlgorithm | None, output: QgsProcessingModelOutput | None) QgsModelComponentGraphicItem | None

Creates a new graphic item for a model output.

Parameters:
Return type:

Optional[QgsModelComponentGraphicItem]

createParameterGraphicItem(self, model: QgsProcessingModelAlgorithm | None, param: QgsProcessingModelParameter | None) QgsModelComponentGraphicItem | None

Creates a new graphic item for a model parameter.

Parameters:
Return type:

Optional[QgsModelComponentGraphicItem]

customEvent(self, a0: QEvent | None)
deselectAll(self)

Clears any selected items in the scene.

Call this method rather than QGraphicsScene.clearSelection, as the latter does not correctly emit signals to allow the scene’s model to update.

disconnectNotify(self, signal: QMetaMethod)
dragEnterEvent(self, event: QGraphicsSceneDragDropEvent | None)
dragLeaveEvent(self, event: QGraphicsSceneDragDropEvent | None)
dragMoveEvent(self, event: QGraphicsSceneDragDropEvent | None)
drawBackground(self, painter: QPainter | None, rect: QRectF)
drawForeground(self, painter: QPainter | None, rect: QRectF)
dropEvent(self, event: QGraphicsSceneDragDropEvent | None)
event(self, event: QEvent | None) bool
eventFilter(self, watched: QObject | None, event: QEvent | None) bool
flags(self) QgsModelGraphicsScene.Flags

Returns the current combination of flags set for the scene.

See also

setFlags()

See also

setFlag()

Return type:

QgsModelGraphicsScene.Flags

focusInEvent(self, event: QFocusEvent | None)
focusNextPrevChild(self, next: bool) bool
focusOutEvent(self, event: QFocusEvent | None)
groupBoxItem(self, uuid: str | None) QgsModelComponentGraphicItem | None

Returns the graphic item corresponding to the specified group box uuid.

Parameters:

uuid (Optional[str])

Return type:

Optional[QgsModelComponentGraphicItem]

helpEvent(self, event: QGraphicsSceneHelpEvent | None)
inputMethodEvent(self, event: QInputMethodEvent | None)
isSignalConnected(self, signal: QMetaMethod) bool
keyPressEvent(self, event: QKeyEvent | None)
keyReleaseEvent(self, event: QKeyEvent | None)
messageBar(self) QgsMessageBar | None

Returns the message bar associated with the scene.

See also

setMessageBar()

Return type:

Optional[QgsMessageBar]

model(self) QgsProcessingModelAlgorithm | None
Return type:

Optional[QgsProcessingModelAlgorithm]

mouseDoubleClickEvent(self, event: QGraphicsSceneMouseEvent | None)
mouseMoveEvent(self, event: QGraphicsSceneMouseEvent | None)
mousePressEvent(self, event: QGraphicsSceneMouseEvent | None)
Parameters:

event (Optional[QGraphicsSceneMouseEvent])

mouseReleaseEvent(self, event: QGraphicsSceneMouseEvent | None)
rebuildRequired

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

receivers(self, signal: PYQT_SIGNAL) int
runFromChild

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

runSelected

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

selectAll(self)

Selects all the components in the scene.

selectedComponentItems(self) List[QgsModelComponentGraphicItem]

Returns list of selected component items.

Return type:

List[QgsModelComponentGraphicItem]

selectedItemChanged

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

sender(self) QObject | None
senderSignalIndex(self) int
setFlag(self, flag: QgsModelGraphicsScene.Flag, on: bool = True)

Enables or disables a particular flag for the scene. Other existing flags are not affected.

See also

setFlags()

See also

flags()

Parameters:
setFlags(self, flags: QgsModelGraphicsScene.Flags | QgsModelGraphicsScene.Flag)

Sets the combination of flags controlling how the scene is rendered and behaves.

See also

setFlag()

See also

flags()

Parameters:

flags (Union[QgsModelGraphicsScene.Flags)

setLastRunResult(self, result: QgsProcessingModelResult)

Sets the result of the last run of the model through the designer window.

Parameters:

result (QgsProcessingModelResult)

setMessageBar(self, bar: QgsMessageBar | None)

Sets the message bar associated with the scene.

See also

messageBar()

Parameters:

bar (Optional[QgsMessageBar])

setModel(self, model: QgsProcessingModelAlgorithm | None)
Parameters:

model (Optional[QgsProcessingModelAlgorithm])

setSelectedItem(self, item: QgsModelComponentGraphicItem | None)

Clears any selected items and sets item as the current selection.

Parameters:

item (Optional[QgsModelComponentGraphicItem])

showChildAlgorithmLog

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

showChildAlgorithmOutputs

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

showWarning(self, shortMessage: str | None, title: str | None, longMessage: str | None, level: Qgis.MessageLevel = Qgis.MessageLevel.Warning)

Shows a warning message, allowing users to click a button to see the full details (longMessage).

Parameters:
  • shortMessage (Optional[str])

  • title (Optional[str])

  • longMessage (Optional[str])

  • level (Qgis.MessageLevel = Qgis.MessageLevel.Warning)

timerEvent(self, a0: QTimerEvent | None)
wheelEvent(self, event: QGraphicsSceneWheelEvent | None)