1

I'm working with a QGIS plugin widget and I have a box which creates a temporary table as an output. I've created the box using the QgsProcessingParameterFeatureSink class. Here is how I created my box in the initAlgorithm and created a feature sink in the processAlgorithm:

class EstimateEcosystemServiceValuesForStudyRegion(QgsProcessingAlgorithm):
    OUTPUT_ESV_TABLE = 'OUTPUT_ESV_TABLE'

    def initAlgorithm(self, config):
        self.addParameter(
        QgsProcessingParameterFeatureSink(
            self.OUTPUT_ESV_TABLE,
            self.tr("Output ESV Table")))

    def processAlgorithm(self, parameters, context, feedback):
        #I created the output_esv_table_fields in another part of the code
        (sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT_ESV_TABLE, context, output_esv_table_fields)

This box creates a (temporary) output table, which I put some data into. The plugin only works if the user leaves this box empty. If I try to specify a name I get the following unknown error: enter image description here

Line 284 in my code is this line from the above code example:

(sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT_ESV_TABLE, context, output_esv_table_fields)

This unknown error doesn't tell me much about how to fix it. Also, it is bad from a User Experience perspective to have a widget box which you must leave empty. So I tried removing the box completely.

Now when I run the widget (with this box removed), QGIS just crashes. It seems I must declare an output parameter for this feature sink object, but I am confused because the user doesn't input anything in the widget box.

Can I remove the feature sink box, but still produce this table as an output?

  • There's not enough context here to diagnose the issue - can you share more of your code? Also, what do you mean by "box"? – ndawson Apr 1 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.