PDA

View Full Version : QwtPlotCurve setZ() removes old LegendLabel and adds a new one



solove
29th September 2015, 08:33
Hello,

so i have an application where a lot of curves can be on the plot at one time. I have written a method that lets me select one of these curves by clicking on it.
To indicate clearly that this line has been selected i set the color of it to red and increase the width.
Now i also want to get this curve to be drawn on top of all the other curves.
To do this i use the setZ() method of QwtPlotCurve and it works just fine.
But my problem is that everytime i use setZ() on a Curve the associated LegendLabel gets removed and a new one gets attached to my Legend and is now deselected and not in the position it was at the beginning.
I need the LegendLabel to stay selected (which is no problem) and also be in the same position.

Is there any way i can avoid that a new LegendLabel gets added or find out the position of the old LegendLabel and put the new LegendLabel in the same position?
The Version im using is 6.1.0

Solove.

Uwe
29th September 2015, 19:44
The connection between plot widget and legend is depending on the QwtPlot::legendDataChanged() signal. So you could try something like this:


item->plot()->blockSignals( true );
item->setZ( ... );
item->plot()->blockSignals( false );Uwe

solove
30th September 2015, 11:49
Thank you very much. Works exactly like i wanted.

solove