[QGIS-Developer] Qt Model-View updates blocked when Python console not open

Richard Duivenvoorde rdmailings at duif.net
Thu Oct 5 23:41:15 PDT 2017


And to make things easier, use

https://github.com/boundlessgeo/lib-qgis-commons/blob/master/qgiscommons2/network/networkaccessmanager.py

which should be core class in QGIS if you ask me. So we can get rid of
all other different blocking/nonproxying etc ways to connect QGIS to http...

Regards,

Richard Duivenvoorde

On 05-10-17 22:01, Ricardo Filipe Soares Garcia da wrote:
> Hi Peter
> 
> In addition to Matthias' advice perhaps try using
> QNetworkAccessManager[1] and related classes in order to deal with your
> http requests asynchronously. This should fix the UI blocking issues.
> 
> Best regards
> 
> 
> [1]
>http://pyqt.sourceforge.net/Docs/PyQt4/qnetworkaccessmanager.html#details
> 
> 
> Em 05/10/2017 15:18, "Matthias Kuhn" <matthias at opengis.ch
> <mailto:matthias at opengis.ch>> escreveu:
> 
>     Hi Peter,
> 
>     Have a look at this answer here, which explains how you can trigger
>     the same behavior without using the print and relying on
>     side-effects of the console open.
> 
>     It also outlines the risks involved in using this kind of approach.
> 
>     https://gis.stackexchange.com/a/257016
>     <https://gis.stackexchange.com/a/257016>
> 
>     Cheers
>     Matthias
> 
> 
>     On 10/05/2017 03:25 PM, Peter Devoy wrote:
> 
>         Just a little update; it is the fact I am using print() to output
>         debug information upon each request which is allowing the UI to
>         repaint.  Also, it seems that opening and closing the Python console
>         once is enough.
> 
>         Peter
> 
>         3XE
>         P: 01326 567155
>         M: 07770 693662
>         A: 3XE Ltd
>         Tremough Innovation Centre
>         PENRYN
>         TR10 9TA
>         3XE Ltd · Registered in England and Wales · 9356871
> 
> 
>         On 4 October 2017 at 20:53, Peter Devoy <peter at 3xe.co.uk
>         <mailto:peter at 3xe.co.uk>> wrote:
> 
>             Hi all
> 
>             In my plugin I have extended QAbstractListModel to create a
>             list of
>             objects; each object in the list has a 'url' property
>             containing the
>             URL of an API resource.  When the user selects a feature in
>             main QGIS
>             interface, each object in the list makes a HTTP request to
>             its URL and
>             updates its properties from the response data.
> 
>             Changes in the objects' properties are reflected in a
>             QListView.  E.g.
>             a  property 'status'  is set to 'WARN' if the HTTP request
>             fails --
>             this is reflected in the QListView by the respective list
>             item's icon
>             turning yellow.
> 
>             If I have the Python console open in QGIS the QListView
>             items update
>             as the ListModel's objects update. However, if the Python
>             console is
>             not open, the plugin's UI thread appears to be blocked until
>             each item
>             in the list has completed its changes and all the items
>             update at
>             once; please can anyone recommend a way to avoid this?
> 
>             I have been developing on QGIS 2.1X.
> 
>             Kind regards
> 
> 
>             Peter
> 
>         _______________________________________________
>         QGIS-Developer mailing list
>         QGIS-Developer at lists.osgeo.org
>         <mailto:QGIS-Developer at lists.osgeo.org>
>         List info:
>         https://lists.osgeo.org/mailman/listinfo/qgis-developer
>         <https://lists.osgeo.org/mailman/listinfo/qgis-developer>
>         Unsubscribe:
>         https://lists.osgeo.org/mailman/listinfo/qgis-developer
>         <https://lists.osgeo.org/mailman/listinfo/qgis-developer>
> 
> 
>     _______________________________________________
>     QGIS-Developer mailing list
>     QGIS-Developer at lists.osgeo.org <mailto:QGIS-Developer at lists.osgeo.org>
>     List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>     <https://lists.osgeo.org/mailman/listinfo/qgis-developer>
>     Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>     <https://lists.osgeo.org/mailman/listinfo/qgis-developer>
> 
> 
> 
> 
> _______________________________________________
> 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
> 



More information about the QGIS-Developer mailing list