[Qgis-developer] Need help with LayerTreeModel (legend node)

Martin Dobias wonder.sk at gmail.com
Fri Dec 19 00:35:39 PST 2014

Hi Sandro

On Fri, Dec 19, 2014 at 12:37 AM, Sandro Santilli <strk at keybit.net> wrote:
> On Thu, Dec 18, 2014 at 01:46:21PM +0100, Sandro Santilli wrote:
> > The weird looking aspect seems to be due to a discrepancy between
> > the actual legend image size and the space reserved for it.
> > In practice I have 2 layers and the layer node for second one gets
> > rendered right below the first one, with the legend of the first one
> > being printed _over_ the layer node of the second, which moves down
> > to the correct place on next redraw.
> >
> > Could this be a bug in the QgsLayerTreeView ?

Most likely you just do not emit dataChanged() where it should be (I have
seen this kind of errors in various models and this was a common problem).
You can try using the model with plain QTreeView - it will most likely have
the same issue.

> I've tried calling recursivelyEmitDataChanged() from
> QgsLayerTreeModel::legendNodeDataChanged() and it effectively
> fixes that problem. Is is overkill to always force redraw of the
> whole layertree ? Sounds pretty fast to me...

That does not look right, it looks like fixing the problem in a wrong way.
That call was made to really force reload of all items when font settings
have changed.

But maybe there's a bug that'd be better fixed ?
> I guess it's currently not exposed because no legend item updates
> by changing its size ?

Maybe a missing emit dataChanged() in
QgsWMSLegendNode::invalidateMapBasedData() ? Just guessing...


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20141219/1339561f/attachment.html>

More information about the Qgis-developer mailing list