Class: QgsExpressionLineEdit

class qgis.gui.QgsExpressionLineEdit(parent: QWidget = None)

Bases: PyQt5.QtWidgets.QWidget

Constructor for QgsExpressionLineEdit.

Parameters

parent – parent widget

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.

New in version 3.0: Enums

Methods

actionEvent

changeEvent

childEvent

closeEvent

connectNotify

contextMenuEvent

create

customEvent

destroy

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

dropEvent

enterEvent

event

expectedOutputFormat

Returns the expected format string, which is shown in the expression builder dialog for the widget.

expression

Returns the current expression shown in the widget.

expressionDialogTitle

Returns the title used for the expression dialog.

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPreviousChild

hideEvent

initPainter

inputMethodEvent

isSignalConnected

isValidExpression

Returns true if the current expression is valid.

keyPressEvent

keyReleaseEvent

leaveEvent

metric

mouseDoubleClickEvent

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

moveEvent

nativeEvent

paintEvent

receivers

registerExpressionContextGenerator

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

resizeEvent

sender

senderSignalIndex

setExpectedOutputFormat

Set the expected format string, which is shown in the expression builder dialog for the widget.

setExpression

Sets the current expression to show in the widget.

setExpressionDialogTitle

Sets the title used in the expression builder dialog

setGeomCalculator

Set the geometry calculator used in the expression dialog.

setLayer

Sets a layer associated with the widget.

setMultiLine

Sets whether the widget should show a multiline text editor.

sharedPainter

showEvent

tabletEvent

timerEvent

updateMicroFocus

wheelEvent

Signals

expressionChanged

Emitted when the expression is changed.

Attributes

actionEvent()
changeEvent(self, event: QEvent)
childEvent()
closeEvent()
connectNotify()
contextMenuEvent()
create()
customEvent()
destroy()
disconnectNotify()
dragEnterEvent()
dragLeaveEvent()
dragMoveEvent()
dropEvent()
enterEvent()
event()
expectedOutputFormat(self) → str

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.

New in version 3.4.

expression(self) → str

Returns the current expression shown in the widget.

See also

setExpression()

expressionChanged

Emitted when the expression is changed.

Parameters

expression – new expression [signal]

expressionDialogTitle(self) → str

Returns the title used for the expression dialog.

focusInEvent()
focusNextChild()
focusNextPrevChild()
focusOutEvent()
focusPreviousChild()
hideEvent()
initPainter()
inputMethodEvent()
isSignalConnected()
isValidExpression(self) → Tuple[bool, str]

Returns true if the current expression is valid.

Parameters

expressionError – will be set to any generated error message if specified

keyPressEvent()
keyReleaseEvent()
leaveEvent()
metric()
mouseDoubleClickEvent()
mouseMoveEvent()
mousePressEvent()
mouseReleaseEvent()
moveEvent()
nativeEvent()
paintEvent()
receivers()
registerExpressionContextGenerator(self, generator: QgsExpressionContextGenerator)

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

Parameters

generator – A QgsExpressionContextGenerator class that will be used to create an expression context when required.

resizeEvent()
sender()
senderSignalIndex()
setExpectedOutputFormat(self, expected: str)

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.

New in version 3.4.

setExpression(self, expression: str)

Sets the current expression to show in the widget.

Parameters

expression – expression string

See also

expression()

setExpressionDialogTitle(self, title: str)

Sets the title used in the expression builder dialog

Parameters

title – dialog title

setGeomCalculator(self, distanceArea: QgsDistanceArea)

Set the geometry calculator used in the expression dialog.

Parameters

distanceArea – calculator

setLayer(self, layer: QgsVectorLayer)

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.

setMultiLine(self, multiLine: bool)

Sets whether the widget should show a multiline text editor.

Parameters

multiLine – set to true to show multiline editor, or false to show single line editor (the default).

sharedPainter()
showEvent()
tabletEvent()
timerEvent()
updateMicroFocus()
wheelEvent()