Class: QgsVariableEditorWidget

A tree based widget for editing expression context scope variables.

The widget allows editing variables from a QgsExpressionContextScope, and can optionally also show inherited variables from a QgsExpressionContext.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsVariableEditorWidget

Base classes

QWidget

QObject

QPaintDevice

class qgis.gui.QgsVariableEditorWidget[source]

Bases: QWidget

__init__(parent: QWidget | None = None)

Constructor for QgsVariableEditorWidget.

Parameters:

parent (Optional[QWidget] = None) – parent widget

context(self) QgsExpressionContext | None[source]

Returns the current expression context for the widget. QgsVariableEditorWidget widgets are created with an empty context by default.

See also

setContext()

Return type:

Optional[QgsExpressionContext]

editableScope(self) QgsExpressionContextScope | None[source]

Returns the current editable scope for the widget.

Return type:

Optional[QgsExpressionContextScope]

Returns:

editable scope, or None if no editable scope is set

reloadContext(self)[source]

Reloads all scopes from the editor’s current context. This method should be called after adding or removing scopes from the attached context.

See also

context()

signal scopeChanged[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.

setContext(self, context: QgsExpressionContext | None)[source]

Overwrites the QgsExpressionContext for the widget. Setting a context allows the widget to show all inherited variables for the context, and highlight any overridden variables within scopes.

Parameters:

context (Optional[QgsExpressionContext]) – expression context

See also

context()

setEditableScopeIndex(self, scopeIndex: int)[source]

Sets the editable scope for the widget. Only variables from the editable scope can be modified by users.

Parameters:

scopeIndex (int) – index of current editable scope. Set to -1 to disable editing and make the widget read-only.

See also

editableScope()

setSettingGroup(self, group: str | None)[source]

Sets the setting group for the widget. QgsVariableEditorWidget widgets with the same setting group will synchronise their settings, e.g., the size of columns in the tree widget.

Parameters:

group (Optional[str]) – setting group

See also

settingGroup()

settingGroup(self) str[source]

Returns the setting group for the widget. QgsVariableEditorWidget widgets with the same setting group will synchronise their settings, e.g., the size of columns in the tree widget.

Return type:

str

Returns:

setting group name

variablesInActiveScope(self) Dict[str, Any][source]

Returns a map variables set within the editable scope. Read only variables are not returned. This method can be used to retrieve the variables edited an added by users via the widget.

Return type:

Dict[str, Any]