<div dir="ltr">I have been trying to run a processing algorithm that generates a table from the stats calculated from an input point layer. After the processing algorithm is run I display an external dialog window and populate that window with the output results of the processing algorithm. I like using the processing toolbox because the algorithms run in their own thread and allow the user to continue working. I don't know if what I am trying to do is completely possible or not but I am most of the way there, but I have encountered one problem that I am not sure how to solve. Here is what I have so far<div><br></div><div>I run my processing algorithm and then in <font face="monospace">postProcessingAlgorithm </font>I open up the dialog window as follows. Note for right now I am calling the plugin "testcapabilities'. The returned result from <font face="monospace">processAlgorithm </font>is a table. </div><div><br></div><div><br></div><div><font face="monospace" size="1">from qgis.utils import plugins</font></div><div><font face="monospace" size="1">...</font></div><div><font face="monospace" size="1"> def processAlgorithm(self, parameters, context, feedback):</font></div><div><font face="monospace" size="1">...</font></div><div><font face="monospace" size="1"> return {self.PrmOutputResults: self.dest_id}<br></font></div><div><font face="monospace" size="1">...</font></div><div><font face="monospace" size="1"> def postProcessAlgorithm(self, context, feedback):<br> retval = super().postProcessAlgorithm(context, feedback)</font></div><div><font face="monospace" size="1"> # This gives me access to the root of my plugin which contains both the</font></div><div><font face="monospace" size="1"> # processing algorithm and the post analysis window.<br> plugin = plugins['testcapabilities']<br> plugin.showDialog() # This opens up my dialog window</font></div><div><font face="monospace" size="1"> # This is the input point vector layer in the processing algorithm<br> input_layer = self.parameterAsLayer(self.parameters, self.PrmInputLayer, context)</font></div><div><font face="monospace" size="1"> # I believe this gives me access to the table layer I generated in the algorithm<br> table_layer = QgsProcessingUtils.mapLayerFromString(self.dest_id, context)</font></div><div><font face="monospace" size="1"> # This is to attach the input and table layers to my dialogs QgsMaplayerComboBox widgets<br> plugin.setData(input_layer,
table_layer)<br> return retval</font><br></div><div><br></div><div>This successfully displays the dialog and passes on the
<span style="font-family:monospace">input_layer</span> to the dialog box and will display it in a QgsMaplayerComboBox in the dialog. The table generated in <font face="monospace">processAlgorithm </font>is valid in <font face="monospace">postProcessAlgorithm</font>, but if I try to have it displayed in a QgsMaplayerComboBox, it does not work. I think the reason is because it has not yet been added to the QGS map layers.</div><div><br></div><div>Is there a QgsProcessingAlgorithm method that is called after the output layer has been added to the QGIS layers panel? If there is then at that point I should be able to add it to my dialog box.</div><div><br></div><div>If this is not possible, then I won't be able to use the processing toolbox and will need to deal with implementing it in my own dialog box and in a separate thread.</div><div><br></div><div>Thanks,</div><div><br></div><div>Calvin</div></div>