Class: QgsModelGraphicsScene

QGraphicsScene subclass representing the model designer.

Warning

Not stable API

Added in version 3.14.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsModelGraphicsScene

Base classes

QGraphicsScene

QObject

Methods

childAlgorithmItem

Returns the graphic item corresponding to the specified child algorithm

componentItemAt

Returns the topmost component item at a specified position.

createGroupBoxGraphicItem

Creates a new graphic item for a model group box.

createItems

Populates the scene by creating items representing the specified model.

deselectAll

Clears any selected items in the scene.

flags

Returns the current combination of flags set for the scene.

groupBoxItem

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

messageBar

Returns the message bar associated with the scene.

model

parameterItem

Returns the QgsModelComponentGraphicItem corresponding to the specified child algorithm

requestRebuildRequired

Requests a complete rebuild of a model by emitting the according signal

selectAll

Selects all the components in the scene.

selectedComponentItems

Returns list of selected component items.

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

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).

updateBounds

Updates the scene rect based on the bounds of the model.

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsModelGraphicsScene. See the FAQ for more details.

createChildAlgGraphicItem

Creates a new graphic item for a model child algorithm.

createCommentGraphicItem

Creates a new graphic item for a model comment.

createOutputGraphicItem

Creates a new graphic item for a model output.

createParameterGraphicItem

Creates a new graphic item for a model parameter.

Signals

componentAboutToChange

Emitted whenever a component of the model is about to be changed.

componentChanged

Emitted whenever a component of the model is changed.

rebuildRequired

Emitted when a change in the model requires a full rebuild of the scene.

runFromChild

Emitted when the user opts to run the part of the model starting from the specified child algorithm.

runSelected

Emitted when the user opts to run selected steps from the model.

selectedItemChanged

Emitted whenever the selected item changes.

showChildAlgorithmLog

Emitted when the user opts to view the previous log from the child algorithm with matching ID.

showChildAlgorithmOutputs

Emitted when the user opts to view previous results from the child algorithm with matching ID.

Attributes

ArrowLink

FlagHideComments

FlagHideControls

GroupBox

ModelComponent

MouseHandles

RubberBand

ZSnapIndicator

class qgis.gui.QgsModelGraphicsScene[source]

Bases: QGraphicsScene

__init__(parent: QObject | None = None)

Constructor for QgsModelGraphicsScene with the specified parent object.

Parameters:

parent (Optional[QObject] = None)

class Flag

Bases: int

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

Bases: object

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

Bases: int

childAlgorithmItem(self, childId: str | None) QgsModelChildAlgorithmGraphicItem | None[source]

Returns the graphic item corresponding to the specified child algorithm

Added in version 3.44.

Parameters:

childId (Optional[str])

Return type:

Optional[QgsModelChildAlgorithmGraphicItem]

signal componentAboutToChange(text: str, id: int = 0)[source]

Emitted whenever a component of the model is about to be changed.

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.

Parameters:
  • text (str)

  • id (int = 0)

signal componentChanged[source]

Emitted whenever a component of the model is changed.

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

Returns the topmost component item at a specified position.

Parameters:

position (Union[QPointF, QPoint])

Return type:

Optional[QgsModelComponentGraphicItem]

virtual createChildAlgGraphicItem(self, model: QgsProcessingModelAlgorithm | None, child: QgsProcessingModelChildAlgorithm | None) QgsModelChildAlgorithmGraphicItem | None[source]

Creates a new graphic item for a model child algorithm.

Parameters:
Return type:

Optional[QgsModelChildAlgorithmGraphicItem]

virtual createCommentGraphicItem(self, model: QgsProcessingModelAlgorithm | None, comment: QgsProcessingModelComment | None, parentItem: QgsModelComponentGraphicItem | None) QgsModelComponentGraphicItem | None[source]

Creates a new graphic item for a model comment.

Parameters:
Return type:

Optional[QgsModelComponentGraphicItem]

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

Creates a new graphic item for a model group box.

Parameters:
Return type:

Optional[QgsModelComponentGraphicItem]

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

Populates the scene by creating items representing the specified model.

Parameters:
virtual createOutputGraphicItem(self, model: QgsProcessingModelAlgorithm | None, output: QgsProcessingModelOutput | None) QgsModelComponentGraphicItem | None[source]

Creates a new graphic item for a model output.

Parameters:
Return type:

Optional[QgsModelComponentGraphicItem]

virtual createParameterGraphicItem(self, model: QgsProcessingModelAlgorithm | None, param: QgsProcessingModelParameter | None) QgsModelComponentGraphicItem | None[source]

Creates a new graphic item for a model parameter.

Parameters:
Return type:

Optional[QgsModelComponentGraphicItem]

deselectAll(self)[source]

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.

flags(self) QgsModelGraphicsScene.Flags[source]

Returns the current combination of flags set for the scene.

See also

setFlags()

See also

setFlag()

Return type:

QgsModelGraphicsScene.Flags

groupBoxItem(self, uuid: str | None) QgsModelComponentGraphicItem | None[source]

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

Parameters:

uuid (Optional[str])

Return type:

Optional[QgsModelComponentGraphicItem]

messageBar(self) QgsMessageBar | None[source]

Returns the message bar associated with the scene.

See also

setMessageBar()

Return type:

Optional[QgsMessageBar]

model(self) QgsProcessingModelAlgorithm | None[source]
Return type:

Optional[QgsProcessingModelAlgorithm]

parameterItem(self, name: str | None) QgsModelComponentGraphicItem | None[source]

Returns the QgsModelComponentGraphicItem corresponding to the specified child algorithm

Added in version 3.44.

Parameters:

name (Optional[str])

Return type:

Optional[QgsModelComponentGraphicItem]

signal rebuildRequired[source]

Emitted when a change in the model requires a full rebuild of the scene.

requestRebuildRequired(self)[source]

Requests a complete rebuild of a model by emitting the according signal

Added in version 3.44.

signal runFromChild(childId: str)[source]

Emitted when the user opts to run the part of the model starting from the specified child algorithm.

Added in version 3.38.

Parameters:

childId (str)

signal runSelected[source]

Emitted when the user opts to run selected steps from the model.

Added in version 3.38.

selectAll(self)[source]

Selects all the components in the scene.

selectedComponentItems(self) List[QgsModelComponentGraphicItem]

Returns list of selected component items.

Return type:

List[QgsModelComponentGraphicItem]

signal selectedItemChanged(selected: QgsModelComponentGraphicItem)[source]

Emitted whenever the selected item changes. If None, no item is selected.

Parameters:

selected (QgsModelComponentGraphicItem)

setFlag(self, flag: QgsModelGraphicsScene.Flag, on: bool = True)[source]

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)[source]

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

See also

setFlag()

See also

flags()

Parameters:

flags (Union[QgsModelGraphicsScene.Flags, QgsModelGraphicsScene.Flag])

setLastRunResult(self, result: QgsProcessingModelResult)[source]

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

Parameters:

result (QgsProcessingModelResult)

setMessageBar(self, bar: QgsMessageBar | None)[source]

Sets the message bar associated with the scene.

See also

messageBar()

Parameters:

bar (Optional[QgsMessageBar])

setModel(self, model: QgsProcessingModelAlgorithm | None)[source]
Parameters:

model (Optional[QgsProcessingModelAlgorithm])

setSelectedItem(self, item: QgsModelComponentGraphicItem | None)[source]

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

Parameters:

item (Optional[QgsModelComponentGraphicItem])

signal showChildAlgorithmLog(childId: str)[source]

Emitted when the user opts to view the previous log from the child algorithm with matching ID.

Added in version 3.38.

Parameters:

childId (str)

signal showChildAlgorithmOutputs(childId: str)[source]

Emitted when the user opts to view previous results from the child algorithm with matching ID.

Added in version 3.38.

Parameters:

childId (str)

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

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)

updateBounds(self)[source]

Updates the scene rect based on the bounds of the model.

The bounding rectangle of the model is calculated off all components of the model, with an additional margin arounds items.

Added in version 4.0.