Class: QgsVariableEditorWidget

class qgis.gui.QgsVariableEditorWidget

Bases: PyQt5.QtWidgets.QWidget

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.

New in version 2.12.

QgsVariableEditorWidget(parent: QWidget = None) Constructor for QgsVariableEditorWidget.

Parameters:

parent

parent widget

Methods

actionEvent

changeEvent

childEvent

closeEvent

connectNotify

context

Returns the current expression context for the widget.

contextMenuEvent

create

customEvent

destroy

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

dropEvent

editableScope

Returns the current editable scope for the widget.

enterEvent

event

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPreviousChild

hideEvent

initPainter

inputMethodEvent

isSignalConnected

keyPressEvent

keyReleaseEvent

leaveEvent

metric

mouseDoubleClickEvent

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

moveEvent

nativeEvent

paintEvent

receivers

reloadContext

Reloads all scopes from the editor's current context.

resizeEvent

sender

senderSignalIndex

setContext

Overwrites the QgsExpressionContext for the widget.

setEditableScopeIndex

Sets the editable scope for the widget.

setSettingGroup

Sets the setting group for the widget.

settingGroup

Returns the setting group for the widget.

sharedPainter

showEvent

param event:

tabletEvent

timerEvent

updateMicroFocus

variablesInActiveScope

Returns a map variables set within the editable scope.

wheelEvent

Signals

scopeChanged

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

actionEvent(self, QActionEvent)
changeEvent(self, QEvent)
childEvent(self, QChildEvent)
closeEvent(self, QCloseEvent)
connectNotify(self, QMetaMethod)
context(self) QgsExpressionContext

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

See also

setContext()

Return type:

QgsExpressionContext

contextMenuEvent(self, QContextMenuEvent)
create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)
customEvent(self, QEvent)
destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
disconnectNotify(self, QMetaMethod)
dragEnterEvent(self, QDragEnterEvent)
dragLeaveEvent(self, QDragLeaveEvent)
dragMoveEvent(self, QDragMoveEvent)
dropEvent(self, QDropEvent)
editableScope(self) QgsExpressionContextScope

Returns the current editable scope for the widget.

Return type:

QgsExpressionContextScope

Returns:

editable scope, or None if no editable scope is set

enterEvent(self, QEvent)
event(self, QEvent) bool
focusInEvent(self, QFocusEvent)
focusNextChild(self) bool
focusNextPrevChild(self, bool) bool
focusOutEvent(self, QFocusEvent)
focusPreviousChild(self) bool
hideEvent(self, QHideEvent)
initPainter(self, QPainter)
inputMethodEvent(self, QInputMethodEvent)
isSignalConnected(self, QMetaMethod) bool
keyPressEvent(self, QKeyEvent)
keyReleaseEvent(self, QKeyEvent)
leaveEvent(self, QEvent)
metric(self, QPaintDevice.PaintDeviceMetric) int
mouseDoubleClickEvent(self, QMouseEvent)
mouseMoveEvent(self, QMouseEvent)
mousePressEvent(self, QMouseEvent)
mouseReleaseEvent(self, QMouseEvent)
moveEvent(self, QMoveEvent)
nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int]
paintEvent(self, QPaintEvent)
receivers(self, PYQT_SIGNAL) int
reloadContext(self)

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

resizeEvent(self, QResizeEvent)
scopeChanged

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
senderSignalIndex(self) int
setContext(self, context: QgsExpressionContext)

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 (QgsExpressionContext) – expression context

See also

context()

setEditableScopeIndex(self, scopeIndex: int)

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)

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 (str) – setting group

See also

settingGroup()

settingGroup(self) str

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

sharedPainter(self) QPainter
showEvent(self, event: QShowEvent)
Parameters:

event (QShowEvent) –

tabletEvent(self, QTabletEvent)
timerEvent(self, QTimerEvent)
updateMicroFocus(self)
variablesInActiveScope(self) Dict[str, Any]

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]

wheelEvent(self, QWheelEvent)