PDA

View Full Version : Controlling order of plot items in Qwt 6.1 Legend



philw
21st October 2015, 23:56
We have both Markers (QwtPlotMarkers) and Curves (QwtPlotCurves) shown in a QwtPlot's legend. See this screenshot:

11463

We would like all Markers to come after all Curves in the legend.

With Qwt 5.2.3, we used to be able to achieve that (Markers coming after Curves) by first turning off, and then turning on again, legend visibility for Markers, like this (mixed pseudo-code):


For all Markers:
marker->setItemAttribute (QwtPlotItem::Legend, false);

For all Markers:
marker->setItemAttribute (QwtPlotItem::Legend, true);
That doesn't have any apparent effect in Qwt 6.1.2. (I tried also doing this instead for the Curves, in case this algorithm was putting the effected QwtPlotItems FIRST instead of LAST in the legend item order. That also had no effect).

In Qwt 6.1, is there a way to control the order of legend items?
Thank you in advance.

philw
22nd October 2015, 02:05
UPDATE ... I did get this to work. The algorithm of "removing" all Markers, and then "re-adding" them works with Qwt 6.1 if you detach/re-attach them, rather than just enabling/disabling their legend-inclusion. That is ...

Qwt 5.2.3 technique:
marker->setItemAttribute (QwtPlotItem::Legend, false);
marker->setItemAttribute (QwtPlotItem::Legend, true);

Qwt 6.1.2 technique:
marker->detach();
marker->attach (this);