QgsSymbolWidgetContext class

Contains settings which reflect the context in which a symbol (or renderer) widget is shown, e.g., the map canvas and relevant expression contexts.

Constructors, destructors, conversion operators

QgsSymbolWidgetContext() defaulted
Constructor for QgsSymbolWidgetContext.
QgsSymbolWidgetContext(const QgsSymbolWidgetContext& other)
Copy constructor.

Public functions

auto additionalExpressionContextScopes() const -> QList<QgsExpressionContextScope>
Returns the list of additional expression context scopes to show as available within the layer.
auto expressionContext() const -> QgsExpressionContext*
Returns the expression context used for the widget, if set.
auto globalProjectAtlasMapLayerScopes(const QgsMapLayer* layer) const -> QList<QgsExpressionContextScope*>
Returns list of scopes: global, project, atlas, map, layer.
auto mapCanvas() const -> QgsMapCanvas*
Returns the map canvas associated with the widget.
auto messageBar() const -> QgsMessageBar*
Returns the message bar associated with the widget.
void setAdditionalExpressionContextScopes(const QList<QgsExpressionContextScope>& scopes)
Sets a list of additional expression context scopes to show as available within the layer.
void setExpressionContext(QgsExpressionContext* context)
Sets the optional expression context used for the widget.
void setMapCanvas(QgsMapCanvas* canvas)
Sets the map canvas associated with the widget.
void setMessageBar(QgsMessageBar* bar)
Sets the message bar associated with the widget.

Function documentation

QgsSymbolWidgetContext::QgsSymbolWidgetContext(const QgsSymbolWidgetContext& other)

Copy constructor.

Parameters
other source QgsSymbolWidgetContext

QList<QgsExpressionContextScope> QgsSymbolWidgetContext::additionalExpressionContextScopes() const

Returns the list of additional expression context scopes to show as available within the layer.

QgsExpressionContext* QgsSymbolWidgetContext::expressionContext() const

Returns the expression context used for the widget, if set.

This expression context is used for evaluating data defined symbol properties and for populating based expression widgets in the layer widget.

QList<QgsExpressionContextScope*> QgsSymbolWidgetContext::globalProjectAtlasMapLayerScopes(const QgsMapLayer* layer) const

Returns list of scopes: global, project, atlas, map, layer.

Ownership is transferred to the caller.

QgsMapCanvas* QgsSymbolWidgetContext::mapCanvas() const

Returns the map canvas associated with the widget.

QgsMessageBar* QgsSymbolWidgetContext::messageBar() const

Returns the message bar associated with the widget.

void QgsSymbolWidgetContext::setAdditionalExpressionContextScopes(const QList<QgsExpressionContextScope>& scopes)

Sets a list of additional expression context scopes to show as available within the layer.

Parameters
scopes list of additional scopes which will be added in order to the end of the default expression context

void QgsSymbolWidgetContext::setExpressionContext(QgsExpressionContext* context)

Sets the optional expression context used for the widget.

Parameters
context expression context pointer. Ownership is not transferred.

This expression context is used for evaluating data defined symbol properties and for populating based expression widgets in the layer widget.

void QgsSymbolWidgetContext::setMapCanvas(QgsMapCanvas* canvas)

Sets the map canvas associated with the widget.

Parameters
canvas map canvas

This allows the widget to retrieve the current map scale and other properties from the canvas.

void QgsSymbolWidgetContext::setMessageBar(QgsMessageBar* bar)

Sets the message bar associated with the widget.

This allows the widget to push feedback messages to the appropriate message bar.