Class: QgsExpressionSelectionDialog

This class offers a dialog to change feature selections. To do so, a QgsExpressionBuilderWidget is shown in a dialog. It offers the possibilities to create a new selection, add to the current selection remove from the current selection or select within the current selection.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsExpressionSelectionDialog

Base classes

QDialog

QWidget

QObject

QPaintDevice

Methods

closeEvent

Implementation for closeEvent Saves the window geometry

done

Implementation for done (default behavior when pressing esc) Calls close, so the window geometry gets saved and the object deleted.

expressionBuilder

The builder widget that is used by the dialog

expressionText

Returns the current expression text

setExpressionText

Sets the current expression text

setGeomCalculator

Sets geometry calculator used in distance/area calculations.

setMapCanvas

Sets a map canvas associated with the dialog.

setMessageBar

Sets the message bar to display feedback from the dialog.

class qgis.gui.QgsExpressionSelectionDialog[source]

Bases: QDialog

__init__(layer: QgsVectorLayer | None, startText: str | None = '', parent: QWidget | None = None)

Creates a new selection dialog.

Parameters:
  • layer (Optional[QgsVectorLayer]) – The layer on which the selection is to be performed.

  • startText (Optional[str] = '') – A default expression text to be applied (Defaults to empty)

  • parent (Optional[QWidget] = None) – parent object (owner)

closeEvent(self, closeEvent: QCloseEvent | None)[source]

Implementation for closeEvent Saves the window geometry

Parameters:

closeEvent (Optional[QCloseEvent]) – Event object. Unused.

done(self, r: int)[source]

Implementation for done (default behavior when pressing esc) Calls close, so the window geometry gets saved and the object deleted.

Parameters:

r (int) – Result value. Unused.

expressionBuilder(self) QgsExpressionBuilderWidget | None[source]

The builder widget that is used by the dialog

Return type:

Optional[QgsExpressionBuilderWidget]

Returns:

The builder widget that is used by the dialog

expressionText(self) str[source]

Returns the current expression text

Return type:

str

Returns:

The expression text

setExpressionText(self, text: str | None)[source]

Sets the current expression text

Parameters:

text (Optional[str]) – the expression text to set

setGeomCalculator(self, da: QgsDistanceArea)[source]

Sets geometry calculator used in distance/area calculations.

Parameters:

da (QgsDistanceArea)

setMapCanvas(self, canvas: QgsMapCanvas | None)[source]

Sets a map canvas associated with the dialog.

Parameters:

canvas (Optional[QgsMapCanvas])

setMessageBar(self, messageBar: QgsMessageBar | None)[source]

Sets the message bar to display feedback from the dialog. This is used when zooming to features to display the count of selected features.

Parameters:

messageBar (Optional[QgsMessageBar]) – target message bar