You might want to use Qwt 6.1 with its new architecture for the plot legends. A legend ( could be a QwtLegend, but any other widget as well - see the stockchart example ) simply connects to a signal of the plot:
void legendDataChanged
( const QwtPlotItem *plotItem,
const QList<QwtLegendData>
&data
)
void legendDataChanged( const QwtPlotItem *plotItem, const QList<QwtLegendData> &data)
To copy to clipboard, switch view to plain text mode
QwtPlot::insertLegend() is still available to insert the legend into the layout system of a plot, but this is optionally. You could also put a legend somewhere in your application layout and connect as many plots as you want to it - by doing the signal/slot connections manually.
3 notes:
- QwtPlot::ExternalLegend has to be replaced by not inserting the legend and setting up the signal/slots connection manually
- Don't be confused, that legendDataChanged emits a list of entries for one plot item. Usually the list will have 1 or 0 entries, but f.e. QwtPlotMultiBarChart needs to show more than entry.
- Unfortunately I will have to modify the API of QwtLegend, so that Qwt 6.1 will be usable for the qwtpolar package as well. But the only consequence for application code will be, that it might have to add some casts for QwtPlotItem.
Uwe
PS: A inserted legend can be removed by: QwtPlot::insertLegend( NULL ).
Bookmarks