I'would export from a processing script (QGIS 3) a vector layer as GPKG. I'm using self.addParameter(QgsProcessingParameterFileDestination(...)) to define the destination file. This method allows user to select the proper extension file (SHP, GPKG, ...) but I'd export the output vector of my script just in GPKG because I'm using QgsVectorFileWriter to create the output, which admits just one type of extension per time. Or I'would save the QgsVectorLayer object that I created in the script with any extension selected by the user.

1 Answer 1


You may try to restrict accepted format in QgsProcessingParameterFileDestination

So, self.addParameter(QgsProcessingParameterFileDestination(...)) could be self.addParameter(QgsProcessingParameterFileDestination(..., fileFilter='GeoPackage (*.gpkg *.GPKG)'))

The name in fileFilter has been deduced from list of filters from execution of QgsVectorFileWriter.fileFilterString(QgsVectorFileWriter.VectorFormatOptions())

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.