QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
|
QgsExpressionPreviewWidget is a widget to preview an expression result. More...
#include <qgsexpressionpreviewwidget.h>
Public Slots | |
void | setCurrentFeature (const QgsFeature &feature) |
sets the current feature used | |
Signals | |
void | evalErrorChanged () |
Will be set to true if the current expression text reported an eval error with the context. | |
void | expressionParsed (bool isValid) |
Emitted when the user changes the expression in the widget. | |
void | parserErrorChanged () |
Will be set to true if the current expression text reported a parser error with the context. | |
void | toolTipChanged (const QString &toolTip) |
Emitted whenever the tool tip changed. | |
Public Member Functions | |
QgsExpressionPreviewWidget (QWidget *parent=nullptr) | |
Constructor. | |
QString | currentPreviewText () const |
Returns the current expression result preview text. | |
bool | evalError () const |
Will be set to true if the current expression text reported an eval error with the context. | |
QgsExpressionContext | expressionContext () const |
Returns the expression context for the widget. | |
bool | parserError () const |
Will be set to true if the current expression text reports a parser error with the context. | |
QList< QgsExpression::ParserError > | parserErrors () const |
Returns the expression parser errors. | |
const QgsExpressionNode * | rootNode () const |
Returns the root node of the expression. | |
void | setCustomPreviewGenerator (const QString &label, const QList< QPair< QString, QVariant > > &choices, const std::function< QgsExpressionContext(const QVariant &) > &previewContextGenerator) |
Sets the widget to run using a custom preview generator. | |
void | setExpressionContext (const QgsExpressionContext &context) |
Sets the expression context for the widget. | |
void | setExpressionText (const QString &expression) |
Sets the expression. | |
void | setGeomCalculator (const QgsDistanceArea &da) |
Sets geometry calculator used in distance/area calculations. | |
void | setLayer (QgsVectorLayer *layer) |
Sets the layer used in the preview. | |
QgsExpressionPreviewWidget is a widget to preview an expression result.
If the layer is set, one can browse across features to see the different outputs.
Definition at line 39 of file qgsexpressionpreviewwidget.h.
|
explicit |
Constructor.
Definition at line 28 of file qgsexpressionpreviewwidget.cpp.
QString QgsExpressionPreviewWidget::currentPreviewText | ( | ) | const |
Returns the current expression result preview text.
Definition at line 230 of file qgsexpressionpreviewwidget.cpp.
bool QgsExpressionPreviewWidget::evalError | ( | ) | const |
Will be set to true
if the current expression text reported an eval error with the context.
Definition at line 244 of file qgsexpressionpreviewwidget.cpp.
|
signal |
Will be set to true
if the current expression text reported an eval error with the context.
|
inline |
Returns the expression context for the widget.
The context is used for the expression preview result and for populating the list of available functions and variables.
Definition at line 113 of file qgsexpressionpreviewwidget.h.
|
signal |
Emitted when the user changes the expression in the widget.
Users of this widget should connect to this signal to decide if to let the user continue.
isValid | Is true if the expression the user has typed is valid. |
bool QgsExpressionPreviewWidget::parserError | ( | ) | const |
Will be set to true
if the current expression text reports a parser error with the context.
Definition at line 225 of file qgsexpressionpreviewwidget.cpp.
|
signal |
Will be set to true
if the current expression text reported a parser error with the context.
|
inline |
Returns the expression parser errors.
Definition at line 141 of file qgsexpressionpreviewwidget.h.
|
inline |
Returns the root node of the expression.
Definition at line 138 of file qgsexpressionpreviewwidget.h.
|
slot |
sets the current feature used
Definition at line 89 of file qgsexpressionpreviewwidget.cpp.
void QgsExpressionPreviewWidget::setCustomPreviewGenerator | ( | const QString & | label, |
const QList< QPair< QString, QVariant > > & | choices, | ||
const std::function< QgsExpressionContext(const QVariant &) > & | previewContextGenerator | ||
) |
Sets the widget to run using a custom preview generator.
In this mode, the widget will call a callback function to generate a new QgsExpressionContext as the previewed object changes. This can be used to provide custom preview values for different objects (i.e. for objects which aren't vector layer features).
label | The label to display for the combo box presenting choices of objects. This should be a representative name, eg "Band" if the widget is showing choices of raster layer bands |
choices | A list of choices to present to the user. Each choice is a pair of a human-readable label and a QVariant representing the object to preview. |
previewContextGenerator | A function which takes a QVariant representing the object to preview, and returns a QgsExpressionContext to use for previewing the object. |
Definition at line 65 of file qgsexpressionpreviewwidget.cpp.
void QgsExpressionPreviewWidget::setExpressionContext | ( | const QgsExpressionContext & | context | ) |
Sets the expression context for the widget.
The context is used for the expression preview result and to populate the list of available functions and variables.
context | expression context |
Definition at line 105 of file qgsexpressionpreviewwidget.cpp.
void QgsExpressionPreviewWidget::setExpressionText | ( | const QString & | expression | ) |
Sets the expression.
Definition at line 80 of file qgsexpressionpreviewwidget.cpp.
void QgsExpressionPreviewWidget::setGeomCalculator | ( | const QgsDistanceArea & | da | ) |
Sets geometry calculator used in distance/area calculations.
Definition at line 99 of file qgsexpressionpreviewwidget.cpp.
void QgsExpressionPreviewWidget::setLayer | ( | QgsVectorLayer * | layer | ) |
Sets the layer used in the preview.
Definition at line 56 of file qgsexpressionpreviewwidget.cpp.
|
signal |
Emitted whenever the tool tip changed.