[QGIS-Developer] process bar in processing algs

Germán Carrillo carrillo.german at gmail.com
Tue Jul 20 06:20:05 PDT 2021


Hi Pierluigi,


you need to create your own *feedback* object and connect its
*progressChanged* SIGNAL to your progressbar's *setValue* SLOT, in this way:


feedback = QgsProcessingFeedback()
feedback.progressChanged.connect(progressBarGrid.setValue)

params_creategrid = {
    # Set key-value parameters
}
result_grid = processing.run("native:creategrid", params_creategrid,
feedback=feedback)


Source: https://gis.stackexchange.com/a/348588/4972


Regards,

Germán

El mar, 20 jul 2021 a las 4:52, matteo (<matteo.ghetta at gmail.com>) escribió:

> Hi Pierluigi,
>
>
> > can you please explain me better?
> > I have self plugin that in particular part use this code
> >
> > result_grid = processing.run("native:creategrid", params_creategrid)
>
> as explained by Prem, if you want to add the progress when you call a
> "native" algorithm of QGIS within your algorithm, then you can pass to
> the algorithm parameters:
>
> result_grid = processing.run("native:creategrid", params_creategrid,
> context=context, feedback=feedback)
>
> be aware also at the `is_child` parameter. Have a look at the example:
>
>
> https://docs.qgis.org/3.4/en/docs/user_manual/processing/scripts.html#extending-qgsprocessingalgorithm
>
> if you want to add steps to the progressBar with your logic then you can
> use feedback.setProgress(number) to fill the progress bar. Have a look
> at the template script and you will find a fine usage
>
> Hope this helps
>
> Matteo
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>


-- 
-----------
   |\__
(:>__)(
   |/
Soluciones Geoinformáticas Libres
http://geotux.tuxfamily.org/
https://twitter.com/GeoTux2 <http://twitter.com/GeoTux2>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210720/12d6493e/attachment.html>


More information about the QGIS-Developer mailing list