2

Is it possible to set the [Skip Output] behaviour as the default for a QgsProcessingParameterFileDestination parameter in a processing script?

enter image description here

I've tried using a None value for the defaultValue parameter, but it remains set as [Save to temporary file].

self.addParameter(
        QgsProcessingParameterFileDestination(
            self.EXPORT_PATH,
            'Export JSON file',
            fileFilter='JSON files (*.json)',
            optional=True,
            defaultValue=None
            
        )
    )

1 Answer 1

2

Only one parameter createByDefault=False was missing:

If createByDefault is false and the parameter is optional, then this destination output will not be created by default.

So, it is supposed to:

self.addParameter(
    QgsProcessingParameterFileDestination(
        name='output',
        description='Export JSON file',
        fileFilter='JSON files (*.json)',
        defaultValue=None,
        optional=True,
        createByDefault=False
        )
    )

The result will be the following:

result

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.