PDA

View Full Version : QwtPlot - What is it made of?



cl90
1st October 2015, 09:06
Hello.

I want to resize the plot itself, and the legend part of the plot.
To do this i think it would be nice to know how a qwtPlot is constructed (what widgets and layouts are contained and how they are arranged)
What i mean is something like this:
11404
This is a screenshot out of the Qt-Creator.
Its easy to see how this Group is constructed. If i want to change spacing or what ever, i just do so by changing the atributes of a layout.

But i have absolutly no idea whats inside a qwtplot. So its hard to change anything.

What i actually want to do is this:
11405
Legend width depends on names. i want to change the width myself.
and: qwtPlot->legend()->setFixedWidth(200); does not help.

HappyCoder
1st October 2015, 12:29
1) look at qwt/playground/plotmatrix
That is an example to manage the alignment of two plots.

2)
If you need a fixed size for your legend, you need to put the widget itself into your layout
(see QwtLegend::legendWidget() ) and check the width of both containers where you put
the legendWidget

Uwe
2nd October 2015, 05:34
QwtPlot::insertLegend() does 2 things:



inserting the legend into the layout system of the plot
connecting the QwtPlot::legendDataChanged() signal with the QwtAbstractLegend::updateLegend() slot


As you don't want (1) I would simply do (2) in application code. Then you can use a QGridLayout with 2 columns putting the plots in the left and the legends in the second one.
( Don't forget to set QwtLegend::setMaxColumns() to set up the number of entries per row inside of the legend ).

Uwe