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

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

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.

signal componentChanged[source]

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.

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]

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.

requestRebuildRequired(self)[source]

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

Added in version 3.44.

signal runFromChild[source]

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.

signal runSelected[source]

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.

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

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.

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

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.

signal showChildAlgorithmOutputs[source]

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.

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.