QgsVariableEditorWidget class
A tree based widget for editing expression context scope variables.
Contents
The widget allows editing variables from a QgsExpressionContextScope, and can optionally also show inherited variables from a QgsExpressionContext.
Constructors, destructors, conversion operators
- QgsVariableEditorWidget(QWidget* parent = nullptr)
- Constructor for QgsVariableEditorWidget.
Public functions
- auto context() const -> QgsExpressionContext*
- Returns the current expression context for the widget.
- auto editableScope() const -> QgsExpressionContextScope*
- Returns the current editable scope for the widget.
- void setContext(QgsExpressionContext* context)
- Overwrites the QgsExpressionContext for the widget.
- void setEditableScopeIndex(int scopeIndex)
- Sets the editable scope for the widget.
- void setSettingGroup(const QString& group)
- Sets the setting group for the widget.
- auto settingGroup() const -> QString
- Returns the setting group for the widget.
- auto variablesInActiveScope() const -> QVariantMap
- Returns a map variables set within the editable scope.
Signals
- void scopeChanged()
- Emitted when the user has modified a scope using the widget.
Public slots
- void reloadContext()
- Reloads all scopes from the editor's current context.
Function documentation
QgsVariableEditorWidget:: QgsVariableEditorWidget(QWidget* parent = nullptr)
Constructor for QgsVariableEditorWidget.
| Parameters | |
|---|---|
| parent | parent widget |
QgsExpressionContext* QgsVariableEditorWidget:: context() const
Returns the current expression context for the widget.
QgsVariableEditorWidget widgets are created with an empty context by default.
QgsExpressionContextScope* QgsVariableEditorWidget:: editableScope() const
Returns the current editable scope for the widget.
| Returns | editable scope, or 0 if no editable scope is set |
|---|
void QgsVariableEditorWidget:: setContext(QgsExpressionContext* context)
Overwrites the QgsExpressionContext for the widget.
| Parameters | |
|---|---|
| context | expression context |
Setting a context allows the widget to show all inherited variables for the context, and highlight any overridden variables within scopes.
void QgsVariableEditorWidget:: setEditableScopeIndex(int scopeIndex)
Sets the editable scope for the widget.
| Parameters | |
|---|---|
| scopeIndex | index of current editable scope. Set to -1 to disable editing and make the widget read-only. |
Only variables from the editable scope can be modified by users.
void QgsVariableEditorWidget:: setSettingGroup(const QString& group)
Sets the setting group for the widget.
| Parameters | |
|---|---|
| group | setting group |
QgsVariableEditorWidget widgets with the same setting group will synchronise their settings, e.g., the size of columns in the tree widget.
QString QgsVariableEditorWidget:: settingGroup() const
Returns the setting group for the widget.
| Returns | setting group name |
|---|
QgsVariableEditorWidget widgets with the same setting group will synchronise their settings, e.g., the size of columns in the tree widget.
QVariantMap QgsVariableEditorWidget:: variablesInActiveScope() const
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.
void QgsVariableEditorWidget:: reloadContext() public slot
Reloads all scopes from the editor's current context.
This method should be called after adding or removing scopes from the attached context.