QGIS API Documentation  3.6.0-Noosa (5873452)
Public Slots | Signals | Public Member Functions | Protected Member Functions | Friends | List of all members
QgsExpressionLineEdit Class Reference

The QgsExpressionLineEdit widget includes a line edit for entering expressions together with a button to open the expression creation dialog. More...

#include <qgsexpressionlineedit.h>

Inheritance diagram for QgsExpressionLineEdit:
Inheritance graph
[legend]

Public Slots

void setExpression (const QString &expression)
 Sets the current expression to show in the widget. More...
 

Signals

void expressionChanged (const QString &expression)
 Emitted when the expression is changed. More...
 

Public Member Functions

 QgsExpressionLineEdit (QWidget *parent=nullptr)
 Constructor for QgsExpressionLineEdit. More...
 
QString expectedOutputFormat () const
 Returns the expected format string, which is shown in the expression builder dialog for the widget. More...
 
QString expression () const
 Returns the current expression shown in the widget. More...
 
QString expressionDialogTitle () const
 Returns the title used for the expression dialog. More...
 
bool isValidExpression (QString *expressionError=nullptr) const
 Determines if the current expression is valid. More...
 
void registerExpressionContextGenerator (const QgsExpressionContextGenerator *generator)
 Register an expression context generator class that will be used to retrieve an expression context for the widget. More...
 
void setExpectedOutputFormat (const QString &expected)
 Set the expected format string, which is shown in the expression builder dialog for the widget. More...
 
void setExpressionDialogTitle (const QString &title)
 Sets the title used in the expression builder dialog. More...
 
void setGeomCalculator (const QgsDistanceArea &distanceArea)
 Set the geometry calculator used in the expression dialog. More...
 
void setLayer (QgsVectorLayer *layer)
 Sets a layer associated with the widget. More...
 
void setMultiLine (bool multiLine)
 Sets whether the widget should show a multiline text editor. More...
 

Protected Member Functions

void changeEvent (QEvent *event) override
 

Friends

class TestQgsFieldExpressionWidget
 

Detailed Description

The QgsExpressionLineEdit widget 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.

Since
QGIS 3.0

Definition at line 49 of file qgsexpressionlineedit.h.

Constructor & Destructor Documentation

◆ QgsExpressionLineEdit()

QgsExpressionLineEdit::QgsExpressionLineEdit ( QWidget *  parent = nullptr)
explicit

Constructor for QgsExpressionLineEdit.

Parameters
parentparent widget

Definition at line 32 of file qgsexpressionlineedit.cpp.

Member Function Documentation

◆ changeEvent()

void QgsExpressionLineEdit::changeEvent ( QEvent *  event)
overrideprotected

Definition at line 191 of file qgsexpressionlineedit.cpp.

◆ expectedOutputFormat()

QString QgsExpressionLineEdit::expectedOutputFormat ( ) const

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
setExpectedOutputFormat()
Since
QGIS 3.4

Definition at line 108 of file qgsexpressionlineedit.cpp.

◆ expression()

QString QgsExpressionLineEdit::expression ( ) const

Returns the current expression shown in the widget.

See also
setExpression()

Definition at line 130 of file qgsexpressionlineedit.cpp.

◆ expressionChanged

void QgsExpressionLineEdit::expressionChanged ( const QString &  expression)
signal

Emitted when the expression is changed.

Parameters
expressionnew expression

◆ expressionDialogTitle()

QString QgsExpressionLineEdit::expressionDialogTitle ( ) const
inline

Returns the title used for the expression dialog.

See also
setExpressionDialogTitle()

Definition at line 72 of file qgsexpressionlineedit.h.

◆ isValidExpression()

bool QgsExpressionLineEdit::isValidExpression ( QString *  expressionError = nullptr) const

Determines if the current expression is valid.

Parameters
expressionErrorwill be set to any generated error message if specified
Returns
true if the current expression is valid.

Definition at line 140 of file qgsexpressionlineedit.cpp.

◆ registerExpressionContextGenerator()

void QgsExpressionLineEdit::registerExpressionContextGenerator ( const QgsExpressionContextGenerator generator)

Register an expression context generator class that will be used to retrieve an expression context for the widget.

Parameters
generatorA QgsExpressionContextGenerator class that will be used to create an expression context when required.

Definition at line 146 of file qgsexpressionlineedit.cpp.

◆ setExpectedOutputFormat()

void QgsExpressionLineEdit::setExpectedOutputFormat ( const QString &  expected)

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
expectedOutputFormat()
Since
QGIS 3.4

Definition at line 113 of file qgsexpressionlineedit.cpp.

◆ setExpression

void QgsExpressionLineEdit::setExpression ( const QString &  expression)
slot

Sets the current expression to show in the widget.

Parameters
expressionexpression string
See also
expression()

Definition at line 151 of file qgsexpressionlineedit.cpp.

◆ setExpressionDialogTitle()

void QgsExpressionLineEdit::setExpressionDialogTitle ( const QString &  title)

Sets the title used in the expression builder dialog.

Parameters
titledialog title
See also
expressionDialogTitle()

Definition at line 49 of file qgsexpressionlineedit.cpp.

◆ setGeomCalculator()

void QgsExpressionLineEdit::setGeomCalculator ( const QgsDistanceArea distanceArea)

Set the geometry calculator used in the expression dialog.

Parameters
distanceAreacalculator

Definition at line 118 of file qgsexpressionlineedit.cpp.

◆ setLayer()

void QgsExpressionLineEdit::setLayer ( QgsVectorLayer layer)

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
registerExpressionContextGenerator

Definition at line 123 of file qgsexpressionlineedit.cpp.

◆ setMultiLine()

void QgsExpressionLineEdit::setMultiLine ( bool  multiLine)

Sets whether the widget should show a multiline text editor.

Parameters
multiLineset to true to show multiline editor, or false to show single line editor (the default).

Definition at line 54 of file qgsexpressionlineedit.cpp.

Friends And Related Function Documentation

◆ TestQgsFieldExpressionWidget

friend class TestQgsFieldExpressionWidget
friend

Definition at line 185 of file qgsexpressionlineedit.h.


The documentation for this class was generated from the following files: