QgsVectorLayerSelectedFeatureSource class

QgsFeatureSource subclass for the selected features from a QgsVectorLayer.

Base classes

class QgsFeatureSource
An interface for objects which provide features via a getFeatures method.
class QgsExpressionContextScopeGenerator
Abstract interface for generating an expression context scope.

Constructors, destructors, conversion operators

QgsVectorLayerSelectedFeatureSource(QgsVectorLayer* layer)
Constructor for QgsVectorLayerSelectedFeatureSource, for selected features from the specified layer.

Public functions

auto createExpressionContextScope() const -> QgsExpressionContextScope* override
This method needs to be reimplemented in all classes which implement this interface and return an expression context scope.
auto featureCount() const -> long override
Returns the number of features contained in the source, or -1 if the feature count is unknown.
auto fields() const -> QgsFields override
Returns the fields associated with features in the source.
auto getFeatures(const QgsFeatureRequest& request = QgsFeatureRequest()) const -> QgsFeatureIterator override
Returns an iterator for the features in the source.
auto sourceCrs() const -> QgsCoordinateReferenceSystem override
Returns the coordinate reference system for features in the source.
auto sourceName() const -> QString override
Returns a friendly display name for the source.
auto wkbType() const -> QgsWkbTypes::Type override
Returns the geometry type for features returned by this source.

Function documentation

QgsVectorLayerSelectedFeatureSource::QgsVectorLayerSelectedFeatureSource(QgsVectorLayer* layer)

Constructor for QgsVectorLayerSelectedFeatureSource, for selected features from the specified layer.

The currently selected feature IDs are stored, so change to the layer selection after constructing the QgsVectorLayerSelectedFeatureSource will not be reflected.

QgsExpressionContextScope* QgsVectorLayerSelectedFeatureSource::createExpressionContextScope() const override

This method needs to be reimplemented in all classes which implement this interface and return an expression context scope.

QgsFeatureIterator QgsVectorLayerSelectedFeatureSource::getFeatures(const QgsFeatureRequest& request = QgsFeatureRequest()) const override

Returns an iterator for the features in the source.

An optional request can be used to optimise the returned iterator, eg by restricting the returned attributes or geometry.

QString QgsVectorLayerSelectedFeatureSource::sourceName() const override

Returns a friendly display name for the source.

The returned value can be an empty string.