Class: QgsExpressionPreviewWidget¶
- class qgis.gui.QgsExpressionPreviewWidget¶
Bases:
PyQt5.QtWidgets.QWidget
QgsExpressionPreviewWidget
is a widget to preview an expression result. If the layer is set, one can browse across features to see the different outputs.Added in version 3.14.
QgsExpressionPreviewWidget(parent: QWidget = None) Constructor
Methods
Returns the current expression result preview text.
Will be set to
True
if the current expression text reported an eval error with the context.Returns the expression context for the widget.
Will be set to
True
if the current expression text reports a parser error with the context.Returns the expression parser errors
Returns the root node of the expression
sets the current feature used
Sets the widget to run using a custom preview generator.
Sets the expression context for the widget.
Sets the expression
Sets geometry calculator used in distance/area calculations.
Sets the layer used in the preview
Signals
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
- actionEvent(self, QActionEvent)¶
- changeEvent(self, QEvent)¶
- childEvent(self, QChildEvent)¶
- closeEvent(self, QCloseEvent)¶
- connectNotify(self, QMetaMethod)¶
- contextMenuEvent(self, QContextMenuEvent)¶
- create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)¶
- currentPreviewText(self) str ¶
Returns the current expression result preview text.
Added in version 3.38.
- Return type:
str
- 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)¶
- evalError(self) bool ¶
Will be set to
True
if the current expression text reported an eval error with the context.- Return type:
bool
- evalErrorChanged¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Parameters:
name (str = ...)
revision (int = ...)
arguments (Sequence = ...)
- Return type:
PYQT_SIGNAL
- event(self, QEvent) bool ¶
- expressionContext(self) QgsExpressionContext ¶
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.
See also
- Return type:
- expressionParsed¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Parameters:
name (str = ...)
revision (int = ...)
arguments (Sequence = ...)
- Return type:
PYQT_SIGNAL
- 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 ¶
- 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], PyQt5.sip.voidptr) Tuple[bool, int] ¶
- paintEvent(self, QPaintEvent)¶
- parserError(self) bool ¶
Will be set to
True
if the current expression text reports a parser error with the context.- Return type:
bool
- parserErrorChanged¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Parameters:
name (str = ...)
revision (int = ...)
arguments (Sequence = ...)
- Return type:
PYQT_SIGNAL
- parserErrors(self) List[QgsExpression.ParserError] ¶
Returns the expression parser errors
- Return type:
- receivers(self, PYQT_SIGNAL) int ¶
- resizeEvent(self, QResizeEvent)¶
- rootNode(self) QgsExpressionNode ¶
Returns the root node of the expression
- Return type:
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setCurrentFeature(self, feature: QgsFeature)¶
sets the current feature used
- Parameters:
feature (QgsFeature)
- setCustomPreviewGenerator(self, label: str, choices: Iterable[Tuple[str, Any]], a2: Callable[..., None])¶
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).- Parameters:
label (str) – 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 (Iterable[Tuple[str) – 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.
Added in version 3.38.
- Parameters:
a2 (Callable[...)
- setExpressionContext(self, context: QgsExpressionContext)¶
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.
- Parameters:
context (QgsExpressionContext) – expression context
- setExpressionText(self, expression: str)¶
Sets the expression
- Parameters:
expression (str)
- setGeomCalculator(self, da: QgsDistanceArea)¶
Sets geometry calculator used in distance/area calculations.
- Parameters:
da (QgsDistanceArea)
- setLayer(self, layer: QgsVectorLayer)¶
Sets the layer used in the preview
- Parameters:
layer (QgsVectorLayer)
- showEvent(self, QShowEvent)¶
- tabletEvent(self, QTabletEvent)¶
- timerEvent(self, QTimerEvent)¶
- toolTipChanged¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Parameters:
name (str = ...)
revision (int = ...)
arguments (Sequence = ...)
- Return type:
PYQT_SIGNAL
- updateMicroFocus(self)¶
- wheelEvent(self, QWheelEvent)¶