[QGIS-Developer] repaint layertree/legend

Salvatore Larosa lrssvtml at gmail.com
Mon Oct 19 05:19:44 PDT 2020


Hi Richard,

there is a refreshLayerLegend(QgsLayerTreeLayer) method which
refreshes the layer node.
That should show up the temporal indicator after activating.

Regards,
-SL

On Mon, Oct 19, 2020 at 12:37 PM Richard Duivenvoorde
<rdmailings at duif.net> wrote:
>
> Hi Devs,
>
> I'm puzzled on how to force the LayerManger/Layertree to repaint itself (or parts).
>
> Context: I'm trying to configure a layer via PyQGIS to be 'temporal enabled'.
> All goes well but the little 'Temporal'-indicator does not show up.
>
> Using this to actually enable the layer:
>
> l=iface.mapCanvas().currentLayer()
> p=l.temporalProperties()
> p.setMode(QgsVectorLayerTemporalProperties.ModeFeatureDateTimeInstantFromField)
> p.setStartField('Time')
> p.setDurationUnits(QgsUnitTypes.TemporalUnit.TemporalSeconds)
> p.setFixedDuration(3600)
> p.setIsActive(True) # OK
>
> BUT: the little 'indicator' does not show up. I've tried to throw up some signals
>
> #p.changed.emit() # does not update the Layer Panel
> #v=iface.layerTreeView()
> #v.update() # not working
> #v.repaint() # noep
> #v.currentLayerChanged.emit(l) # nothing
> #QCoreApplication.processEvents() # nope nor working either
>
> I have tried to get the actual indicator:
> n=QgsProject.instance().layerTreeRoot().findLayer(l) # find QgsLayerTreeLayer
> i=iface.layerTreeView().indicators(n)
>
> but no repaint untill I actually click in the Layers panel..
>
> So Question: is there some magic to let this TreeView (which it actually is) to repaint itself?
>
> Which reminds me on an issue I had earlier: IF you change the filter of a layer (via PyQGIS) and that layer had a layer count, then the (visible) count was also not updated untill you clicked the legend.
>
> I'm puzzled to what level I should repaint the widget: full of only one node or...
>
> Any input appreciated.
>
> Regards,
>
> Richard Duivenvoorde
> _______________________________________________
> 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



-- 
Salvatore Larosa
linkedIn: http://linkedin.com/in/larosasalvatore
twitter: @lrssvt
skype: s.larosa
IRC: lrssvt on freenode


More information about the QGIS-Developer mailing list