I wrote a Progressing algorithm using Python. The tool clips DEM by a select polygon in the vector layer. If there is no selection, the tool gives an error. As the script runs anyway for the selected object, I would like to disable the "Selected feature only" option if it is possible.

Any idea if it is possible?

enter image description here

1 Answer 1


Processing adds the Selected features only checkbox if you use a QgsProcessingParameterFeatureSource as input parameter, but it does not add the checkbox if you use a QgsProcessingParameterVectorLayer.


enter image description here

Therefore, in your script, instead of using QgsProcessingParameterFeatureSource as input parameter type, use QgsProcessingParameterVectorLayer. Example:

        self.tr('Input layer with QgsProcessingParameterVectorLayer'),

Now, in processAlgorithm() method, get the parameter in this way:

polygon_layer = self.parameterAsVectorLayer(

NOTE: As you can see in the screenshot above, the QgsProcessingParameterFeatureSource has some advantages over QgsProcessingParameterVectorLayer. So, if you use the latter, you won't get the handy options at the right hand side. Namely, iterate through features and advanced options buttons.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.