diff --git a/python/core/auto_generated/qgsfeaturerequest.sip.in b/python/core/auto_generated/qgsfeaturerequest.sip.in index c823d866ab0..f039a39a8e7 100644 --- a/python/core/auto_generated/qgsfeaturerequest.sip.in +++ b/python/core/auto_generated/qgsfeaturerequest.sip.in @@ -513,6 +513,15 @@ Set a subset of attributes that will be fetched. An empty attributes list indicates that no attributes will be fetched. To revert a call to setSubsetOfAttributes and fetch all available attributes, the SubsetOfAttributes flag should be removed from the request. +%End + + QgsFeatureRequest &setNoAttributes(); +%Docstring +Set that no attributes will be fetched. +To revert a call to setNoAttributes and fetch all or some available attributes, +the SubsetOfAttributes flag should be removed from the request. + +.. versionadded:: 3.4 %End QgsAttributeList subsetOfAttributes() const; diff --git a/src/core/qgsfeaturerequest.cpp b/src/core/qgsfeaturerequest.cpp index 16f38beef8e..acbddd1fc77 100644 --- a/src/core/qgsfeaturerequest.cpp +++ b/src/core/qgsfeaturerequest.cpp @@ -190,6 +190,11 @@ QgsFeatureRequest &QgsFeatureRequest::setSubsetOfAttributes( const QgsAttributeL return *this; } +QgsFeatureRequest &QgsFeatureRequest::setNoAttributes() +{ + return setSubsetOfAttributes( QgsAttributeList() ); +} + QgsFeatureRequest &QgsFeatureRequest::setSubsetOfAttributes( const QStringList &attrNames, const QgsFields &fields ) { if ( attrNames.contains( QgsFeatureRequest::ALL_ATTRIBUTES ) ) diff --git a/src/core/qgsfeaturerequest.h b/src/core/qgsfeaturerequest.h index 1f3d55b955d..a822327f9b8 100644 --- a/src/core/qgsfeaturerequest.h +++ b/src/core/qgsfeaturerequest.h @@ -501,6 +501,14 @@ class CORE_EXPORT QgsFeatureRequest */ QgsFeatureRequest &setSubsetOfAttributes( const QgsAttributeList &attrs ); + /** + * Set that no attributes will be fetched. + * To revert a call to setNoAttributes and fetch all or some available attributes, + * the SubsetOfAttributes flag should be removed from the request. + * \since QGIS 3.4 + */ + QgsFeatureRequest &setNoAttributes(); + /** * Returns the subset of attributes which at least need to be fetched * \returns A list of attributes to be fetched