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:
Methods
- param event
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.
- actionEvent(self, QActionEvent)¶
- changeEvent(self, event: QEvent)¶
- Parameters
event (QEvent) –
- childEvent(self, QChildEvent)¶
- closeEvent(self, QCloseEvent)¶
- connectNotify(self, QMetaMethod)¶
- contextMenuEvent(self, QContextMenuEvent)¶
- create(self, window: sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)¶
- customEvent(self, QEvent)¶
- destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)¶
- disconnectNotify(self, QMetaMethod)¶
- dragEnterEvent(self, QDragEnterEvent)¶
- dragLeaveEvent(self, QDragLeaveEvent)¶
- dragMoveEvent(self, QDragMoveEvent)¶
- dropEvent(self, QDropEvent)¶
- enterEvent(self, QEvent)¶
- event(self, QEvent) bool ¶
- 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.
See also
New in version 3.4.
- Return type
str
- expression(self) str ¶
Returns the current expression shown in the widget.
See also
- Return type
str
- expressionChanged¶
Emitted when the expression is changed.
- Parameters
expression (str) – new expression [signal]
- expressionDialogTitle(self) str ¶
Returns the title used for the expression dialog.
See also
- Return type
str
- focusInEvent(self, QFocusEvent)¶
- focusNextChild(self) bool ¶
- focusNextPrevChild(self, bool) bool ¶
- focusOutEvent(self, QFocusEvent)¶
- focusPreviousChild(self) bool ¶
- hideEvent(self, QHideEvent)¶
- initPainter(self, QPainter)¶
- inputMethodEvent(self, QInputMethodEvent)¶
- isSignalConnected(self, QMetaMethod) bool ¶
- isValidExpression(self) Tuple[bool, str] ¶
Determines if the current expression is valid.
- Return type
Tuple[bool, str]
- Returns
True
if the current expression is valid.expressionError: will be set to any generated error message
- keyPressEvent(self, QKeyEvent)¶
- keyReleaseEvent(self, QKeyEvent)¶
- leaveEvent(self, QEvent)¶
- metric(self, QPaintDevice.PaintDeviceMetric) int ¶
- mouseDoubleClickEvent(self, QMouseEvent)¶
- mouseMoveEvent(self, QMouseEvent)¶
- mousePressEvent(self, QMouseEvent)¶
- mouseReleaseEvent(self, QMouseEvent)¶
- moveEvent(self, QMoveEvent)¶
- nativeEvent(self, Union[QByteArray, bytes, bytearray], sip.voidptr) Tuple[bool, int] ¶
- paintEvent(self, QPaintEvent)¶
- receivers(self, PYQT_SIGNAL) int ¶
- registerExpressionContextGenerator(self, generator: QgsExpressionContextGenerator)¶
Register an expression context generator class that will be used to retrieve an expression context for the widget.
- Parameters
generator (QgsExpressionContextGenerator) – A
QgsExpressionContextGenerator
class that will be used to create an expression context when required.
- resizeEvent(self, QResizeEvent)¶
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- 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.See also
New in version 3.4.
- Parameters
expected (str) –
- setExpression(self, expression: str)¶
Sets the current expression to show in the widget.
- Parameters
expression (str) – expression string
See also
- setExpressionDialogTitle(self, title: str)¶
Sets the title used in the expression builder dialog
- Parameters
title (str) – dialog title
See also
- setGeomCalculator(self, distanceArea: QgsDistanceArea)¶
Set the geometry calculator used in the expression dialog.
- Parameters
distanceArea (QgsDistanceArea) – 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.
See also
- Parameters
layer (QgsVectorLayer) –
- setMultiLine(self, multiLine: bool)¶
Sets whether the widget should show a multiline text editor.
- Parameters
multiLine (bool) – set to
True
to show multiline editor, orFalse
to show single line editor (the default).
- showEvent(self, QShowEvent)¶
- tabletEvent(self, QTabletEvent)¶
- timerEvent(self, QTimerEvent)¶
- updateMicroFocus(self)¶
- wheelEvent(self, QWheelEvent)¶