PDA

View Full Version : QWT 6.1 Customizing Legend Labels and Icon Position



BagpipesJohnson
12th November 2014, 16:04
Hello all,

This is one of my first posts, so feel free to correct any breaches in style/protocol

I am using QWT 6.1 and I have a graph with two axis' and two curves. The blue curve goes with the axis on the left, the red curve with the axis on the right.

The objectives:

Spread out the axis entries.
I know I can do this, but I am having a lot of trouble finding out how to get to the Plot Legend Labels for my curves. (I now that I could add to their margins if I could get to them)

Change the order of label and legend icon
Generally, the legend icon comes before the legend label--I'd like to reverse that so that the icon is to the right of the label that goes with the yRight axis making it absolutely clear to which axis it belongs.

As these are kind of general things, I haven't attached my code, should that be desirable, let me know.

Thank you to everyone!

Uwe
14th November 2014, 09:50
Spread out the axis entries.
Not sure, what is meant here.


Change the order of label and legend icon
This is not supported by QwtLegendLabel, but you could overload:


virtual QWidget *QwtLegend::createWidget( const QwtLegendData & ) const;
virtual void QwtLegend::updateWidget( QWidget *widget, const QwtLegendData &data );
virtual void QwtLegend::renderItem( QPainter *,
const QWidget *, const QRectF &, bool fillBackground ) const;

Uwe

BagpipesJohnson
14th November 2014, 15:34
Uwe,

Thank you for the response--

I was hoping to avoid overloading, but if that's what it is, so be it.

As for spreading out, I mis-spoke--I want to spread out the legend entries, not the axis entries. In the attached screen shot, the blue and the red lines correspond to different y-axis'. I want to spread them out so that the blue legend entry is to the left, near it's axis with the red entry to the right, near its own yRight axis. I was pretty sure that I could get to these if I could get at the plot legend labels--Can you tell me how to get to those?

Thank you!

10746

Uwe
14th November 2014, 16:20
Then you might consider to derive from QwtAbstractLegend, implementing something simple based on a QHBoxLayout of 4 widgets ( 2 icons, 2 labels ) and a stretch in the center.

Uwe