QgsExpressionSelectionDialog class

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.

Constructors, destructors, conversion operators

QgsExpressionSelectionDialog(QgsVectorLayer* layer, const QString& startText = QString(), QWidget* parent = nullptr)
Creates a new selection dialog.

Public functions

auto expressionBuilder() -> QgsExpressionBuilderWidget*
The builder widget that is used by the dialog.
auto expressionText() -> QString
Returns the current expression text.
void setExpressionText(const QString& text)
Sets the current expression text.
void setGeomCalculator(const QgsDistanceArea& da)
Sets geometry calculator used in distance/area calculations.
void setMapCanvas(QgsMapCanvas* canvas)
Sets a map canvas associated with the dialog.
void setMessageBar(QgsMessageBar* messageBar)
Sets the message bar to display feedback from the dialog.

Protected functions

void closeEvent(QCloseEvent* closeEvent) override
Implementation for closeEvent Saves the window geometry.
void done(int r) override
Implementation for done (default behavior when pressing esc) Calls close, so the window geometry gets saved and the object deleted.

Function documentation

QgsExpressionSelectionDialog::QgsExpressionSelectionDialog(QgsVectorLayer* layer, const QString& startText = QString(), QWidget* parent = nullptr)

Creates a new selection dialog.

Parameters
layer The layer on which the selection is to be performed.
startText A default expression text to be applied (Defaults to empty)
parent parent object (owner)

QgsExpressionBuilderWidget* QgsExpressionSelectionDialog::expressionBuilder()

The builder widget that is used by the dialog.

Returns The builder widget that is used by the dialog

QString QgsExpressionSelectionDialog::expressionText()

Returns the current expression text.

Returns The expression text

void QgsExpressionSelectionDialog::setExpressionText(const QString& text)

Sets the current expression text.

Parameters
text the expression text to set

void QgsExpressionSelectionDialog::setMapCanvas(QgsMapCanvas* canvas)

Sets a map canvas associated with the dialog.

void QgsExpressionSelectionDialog::setMessageBar(QgsMessageBar* messageBar)

Sets the message bar to display feedback from the dialog.

Parameters
messageBar target message bar

This is used when zooming to features to display the count of selected features.

void QgsExpressionSelectionDialog::closeEvent(QCloseEvent* closeEvent) override protected

Implementation for closeEvent Saves the window geometry.

Parameters
closeEvent Event object. Unused.

void QgsExpressionSelectionDialog::done(int r) override protected

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

Parameters
r Result value. Unused.