Class: QgsExpressionLineEdit¶
A widget which includes a line edit for entering expressions together with a button to open the expression creation dialog.
This widget is designed for use in contexts where no layer fields are
available for use in an expression. In contexts where the expression is
directly associated with a layer and fields can be used, then
QgsFieldExpressionWidget
is a more appropriate choice as it
gives users direct access to select fields from a drop-down list.
QgsExpressionLineEdit
also supports a multiline editor mode
which is useful where more space is available for the widget, but where
QgsExpressionBuilderWidget
is too complex or large for use.
Class Hierarchy¶
Base classes¶
Methods
Returns the expected format string, which is shown in the expression builder dialog for the widget. |
|
Returns the current expression shown in the widget. |
|
Returns the title used for the expression dialog. |
|
Determines if the current expression is valid. |
|
Register an expression context generator class that will be used to retrieve an expression context for the widget. |
|
Set the expected format string, which is shown in the expression builder dialog for the widget. |
|
Sets the current expression to show in the widget. |
|
Sets the title used in the expression builder dialog |
|
Set the geometry calculator used in the expression dialog. |
|
Sets a layer associated with the widget. |
|
Sets whether the widget should show a multiline text editor. |
Signals
Emitted when the expression is changed. |
- class qgis.gui.QgsExpressionLineEdit[source]¶
Bases:
QWidget
- __init__(parent: QWidget | None = None)
Constructor for QgsExpressionLineEdit.
- Parameters:
parent (Optional[QWidget] = None) – parent widget
- expectedOutputFormat(self) str [source]¶
Returns the expected format string, which is shown in the expression builder dialog for the widget. This is purely a text format and no expression validation is done against it.
See also
Added in version 3.4.
- Return type:
str
- expression(self) str [source]¶
Returns the current expression shown in the widget.
See also
- Return type:
str
- signal expressionChanged(expression: str)[source]¶
Emitted when the expression is changed.
- Parameters:
expression (str) – new expression
- expressionDialogTitle(self) str [source]¶
Returns the title used for the expression dialog.
See also
- Return type:
str
- isValidExpression(self)[source]¶
Determines if the current expression is valid.
- Returns:
True
if the current expression is valid.expressionError: any generated error message
- registerExpressionContextGenerator(self, generator: QgsExpressionContextGenerator | None)[source]¶
Register an expression context generator class that will be used to retrieve an expression context for the widget.
- Parameters:
generator (Optional[QgsExpressionContextGenerator]) – A
QgsExpressionContextGenerator
class that will be used to create an expression context when required.
- setExpectedOutputFormat(self, expected: str | None)[source]¶
Set the
expected
format string, which is shown in the expression builder dialog for the widget. This is purely a text format and no expression validation is done against it.See also
Added in version 3.4.
- Parameters:
expected (Optional[str])
- setExpression(self, expression: str | None)[source]¶
Sets the current expression to show in the widget.
- Parameters:
expression (Optional[str]) – expression string
See also
- setExpressionDialogTitle(self, title: str | None)[source]¶
Sets the title used in the expression builder dialog
- Parameters:
title (Optional[str]) – dialog title
See also
- setGeomCalculator(self, distanceArea: QgsDistanceArea)[source]¶
Set the geometry calculator used in the expression dialog.
- Parameters:
distanceArea (QgsDistanceArea) – calculator
- setLayer(self, layer: QgsVectorLayer | None)[source]¶
Sets a layer associated with the widget. Required in order to get the fields and values from the layer. This will also automatically register the layer as expression context generator if no generator has been set before or the previous layer has been used as generator.
See also
- Parameters:
layer (Optional[QgsVectorLayer])