QwtPlotLegendItem − A class which draws a legend inside the plot canvas.
#include <qwt_plot_legenditem.h>
Inherits QwtPlotItem.
enum
BackgroundMode { LegendBackground,
ItemBackground }
Background mode.
Public Types inherited from QwtPlotItem
enum RttiValues {
Rtti_PlotItem = 0, Rtti_PlotGrid,
Rtti_PlotScale, Rtti_PlotLegend,
Rtti_PlotMarker, Rtti_PlotCurve,
Rtti_PlotSpectroCurve, Rtti_PlotIntervalCurve,
Rtti_PlotHistogram, Rtti_PlotSpectrogram,
Rtti_PlotGraphic, Rtti_PlotTradingCurve,
Rtti_PlotBarChart, Rtti_PlotMultiBarChart,
Rtti_PlotShape, Rtti_PlotTextLabel,
Rtti_PlotZone, Rtti_PlotVectorField,
Rtti_PlotUserItem = 1000 }
Runtime type information.
enum ItemAttribute { Legend = 0x01,
AutoScale = 0x02, Margins = 0x04 }
Plot Item Attributes.
enum ItemInterest { ScaleInterest = 0x01,
LegendInterest = 0x02 }
Plot Item Interests.
enum RenderHint { RenderAntialiased = 0x1 }
Render hints.
typedef QFlags< ItemAttribute >
ItemAttributes
typedef QFlags< ItemInterest >
ItemInterests
typedef QFlags< RenderHint >
RenderHints
QwtPlotLegendItem
()
Constructor.
virtual ˜QwtPlotLegendItem ()
Destructor.
virtual int rtti () const override
void setAlignmentInCanvas (Qt::Alignment)
Set the alignmnet.
Qt::Alignment alignmentInCanvas () const
void setOffsetInCanvas (Qt::Orientations, int
numPixels)
Set the distance between the legend and the canvas border.
int offsetInCanvas (Qt::Orientation) const
void setMaxColumns (uint)
Limit the number of columns.
uint maxColumns () const
void setMargin (int)
Set the margin around legend items.
int margin () const
void setSpacing (int)
Set the spacing between the legend items.
int spacing () const
void setItemMargin (int)
int itemMargin () const
void setItemSpacing (int)
int itemSpacing () const
void setFont (const QFont &)
QFont font () const
void setBorderRadius (double)
double borderRadius () const
void setBorderPen (const QPen &)
QPen borderPen () const
void setBackgroundBrush (const QBrush &)
Set the background brush.
QBrush backgroundBrush () const
void setBackgroundMode (BackgroundMode)
Set the background mode.
BackgroundMode backgroundMode () const
void setTextPen (const QPen &)
Set the pen for drawing text labels.
QPen textPen () const
virtual void draw (QPainter *, const
QwtScaleMap &xMap, const QwtScaleMap
&yMap, const QRectF &canvasRect) const override
void clearLegend ()
Remove all items from the legend.
virtual void updateLegend (const QwtPlotItem
*, const QList< QwtLegendData > &)
override
virtual QRect geometry (const QRectF &canvasRect)
const
virtual QSize minimumSize (const QwtLegendData
&) const
virtual int heightForWidth (const
QwtLegendData &, int width) const
QList< const QwtPlotItem * >
plotItems () const
QList< QRect > legendGeometries (const
QwtPlotItem *) const
Public Member Functions inherited from QwtPlotItem
QwtPlotItem ()
QwtPlotItem (const QString &title)
QwtPlotItem (const QwtText &title)
virtual ˜QwtPlotItem ()
Destroy the QwtPlotItem.
void attach (QwtPlot *plot)
Attach the item to a plot.
void detach ()
This method detaches a QwtPlotItem from any
QwtPlot it has been associated with.
QwtPlot * plot () const
Return attached plot.
void setTitle (const QString &title)
void setTitle (const QwtText
&title)
const QwtText & title () const
void setItemAttribute (ItemAttribute, bool
on=true)
bool testItemAttribute (ItemAttribute) const
void setItemInterest (ItemInterest, bool
on=true)
bool testItemInterest (ItemInterest) const
void setRenderHint (RenderHint, bool on=true)
bool testRenderHint (RenderHint) const
void setRenderThreadCount (uint numThreads)
uint renderThreadCount () const
void setLegendIconSize (const QSize &)
QSize legendIconSize () const
double z () const
void setZ (double z)
Set the z value.
void show ()
Show the item.
void hide ()
Hide the item.
virtual void setVisible (bool)
bool isVisible () const
void setAxes (QwtAxisId xAxis, QwtAxisId
yAxis)
void setXAxis (QwtAxisId)
QwtAxisId xAxis () const
Return xAxis.
void setYAxis (QwtAxisId)
QwtAxisId yAxis () const
Return yAxis.
virtual void itemChanged ()
virtual void legendChanged ()
virtual QRectF boundingRect () const
virtual void getCanvasMarginHint (const
QwtScaleMap &xMap, const QwtScaleMap
&yMap, const QRectF &canvasRect, double &left,
double &top, double &right, double &bottom)
const
Calculate a hint for the canvas margin.
virtual void updateScaleDiv (const QwtScaleDiv
&, const QwtScaleDiv &)
Update the item to changes of the axes scale division.
QRectF scaleRect (const QwtScaleMap &,
const QwtScaleMap &) const
Calculate the bounding scale rectangle of 2 maps.
QRectF paintRect (const QwtScaleMap &,
const QwtScaleMap &) const
Calculate the bounding paint rectangle of 2 maps.
virtual QList< QwtLegendData >
legendData () const
Return all information, that is needed to represent the item
on the legend.
virtual QwtGraphic legendIcon (int index, const
QSizeF &) const
virtual void
drawLegendData (QPainter *, const QwtPlotItem
*, const QwtLegendData &, const QRectF &)
const
virtual void drawBackground (QPainter *, const QRectF
&rect) const
Protected Member Functions inherited from QwtPlotItem
QwtGraphic defaultIcon
(const QBrush &, const QSizeF &) const
Return a default icon from a brush.
A class which draws a legend inside the plot canvas.
QwtPlotLegendItem can be used to draw a inside the plot canvas. It can be used together with a QwtLegend or instead of it to have more space for the plot canvas.
In opposite to QwtLegend the legend item is not interactive. To identify mouse clicks on a legend item an event filter needs to be installed catching mouse events ob the plot canvas. The geometries of the legend items are available using legendGeometries().
The legend item is aligned to plot canvas according to its alignment() flags. It might have a background for the complete legend ( usually semi transparent ) or for each legend item.
Note
An external QwtLegend with a transparent background on top the plot canvas might be another option with a similar effect.
Definition at line 41 of file qwt_plot_legenditem.h.
Background mode. Depending on the mode the complete legend or each item might have an background.
The default setting is LegendBackground.
See also
setBackgroundMode(), setBackgroundBrush(), drawBackground()
Enumerator
LegendBackground
The legend has a background.
ItemBackground
Each item has a background.
Definition at line 54 of file qwt_plot_legenditem.h.
Constructor.
Definition at line 175 of file qwt_plot_legenditem.cpp.
Destructor.
Definition at line 185 of file qwt_plot_legenditem.cpp.
Returns
Alignment flags
See also
setAlignmentInCanvas()
Definition at line 223 of file qwt_plot_legenditem.cpp.
Returns
Brush is used to fill the background
See also
setBackgroundBrush(), backgroundMode(), drawBackground()
Definition at line 522 of file qwt_plot_legenditem.cpp.
Returns
backgroundMode
See also
setBackgroundMode(), backgroundBrush(), drawBackground()
Definition at line 550 of file qwt_plot_legenditem.cpp.
Returns
Pen for drawing the border
See also
setBorderPen(), backgroundBrush()
Definition at line 496 of file qwt_plot_legenditem.cpp.
Returns
Radius of the border
See also
setBorderRadius(), setBorderPen()
Definition at line 472 of file qwt_plot_legenditem.cpp.
Remove all items from the legend.
Definition at line 759 of file qwt_plot_legenditem.cpp.
Draw the legend
Parameters
painter Painter
xMap x Scale Map
yMap y Scale Map
canvasRect Contents rectangle of the canvas in painter
coordinates
Implements QwtPlotItem.
Definition at line 587 of file qwt_plot_legenditem.cpp.
Draw a rounded rect
Parameters
painter Painter
rect Bounding rectangle
See also
setBorderRadius(), setBorderPen(), setBackgroundBrush(), setBackgroundMode()
Definition at line 630 of file qwt_plot_legenditem.cpp.
Draw an entry on the legend
Parameters
painter Qt Painter
plotItem Plot item, represented by the entry
data Attributes of the legend entry
rect Bounding rectangle for the entry
Definition at line 780 of file qwt_plot_legenditem.cpp.
Returns
Font used for drawing the text label
See also
setFont()
Definition at line 389 of file qwt_plot_legenditem.cpp.
Calculate the geometry of the legend on the canvas
Parameters
canvasRect Geometry of the canvas
Returns
Geometry of the legend
Definition at line 650 of file qwt_plot_legenditem.cpp.
Returns
The preferred height, for a width.
Parameters
data Attributes of the
legend entry
width Width
Definition at line 862 of file qwt_plot_legenditem.cpp.
Returns
Margin around each item
See also
setItemMargin(), itemSpacing(), margin(), spacing()
Definition at line 335 of file qwt_plot_legenditem.cpp.
Returns
Spacing inside of each item
See also
setItemSpacing(), itemMargin(), margin(), spacing()
Definition at line 363 of file qwt_plot_legenditem.cpp.
Returns
Geometries of the items of a plot item
Note
Usually a plot item has only one entry on the legend
Definition at line 895 of file qwt_plot_legenditem.cpp.
Returns
Margin around the legend items
See also
setMargin(), spacing(), itemMargin(), itemSpacing()
Definition at line 280 of file qwt_plot_legenditem.cpp.
Returns
Maximum number of columns
See also
maxColumns(), QwtDynGridLayout::maxColumns()
Definition at line 251 of file qwt_plot_legenditem.cpp.
Minimum size hint needed to display an entry
Parameters
data Attributes of the legend entry
Returns
Minimum size
Definition at line 823 of file qwt_plot_legenditem.cpp.
Parameters
orientation Qt::Horizontal is for the left/right, Qt::Vertical for the top/bottom padding.
Returns
Distance between the legend and the canvas border
See also
setOffsetInCanvas()
Definition at line 444 of file qwt_plot_legenditem.cpp.
Returns
All plot items with an entry on the legend
Note
A plot item might have more than one entry on the legend
Definition at line 886 of file qwt_plot_legenditem.cpp.
Returns
QwtPlotItem::Rtti_PlotLegend
Reimplemented from QwtPlotItem.
Definition at line 192 of file qwt_plot_legenditem.cpp.
Set the alignmnet. Alignment means the position of the legend relative to the geometry of the plot canvas.
Parameters
alignment Alignment flags
See also
alignmentInCanvas(), setMaxColumns()
Note
To align a legend with many items horizontally the number of columns need to be limited
Definition at line 210 of file qwt_plot_legenditem.cpp.
Set the background brush. The brush is used to fill the background
Parameters
brush Brush
See also
backgroundBrush(), setBackgroundMode(), drawBackground()
Definition at line 509 of file qwt_plot_legenditem.cpp.
Set the background mode. Depending on the mode the complete legend or each item might have an background.
The default setting is LegendBackground.
See also
backgroundMode(), setBackgroundBrush(), drawBackground()
Definition at line 537 of file qwt_plot_legenditem.cpp.
Set the pen for drawing the border
Parameters
pen Border pen
See also
borderPen(), setBackgroundBrush()
Definition at line 483 of file qwt_plot_legenditem.cpp.
Set the radius for the border
Parameters
radius A value <= 0 defines a rectangular border
See also
borderRadius(), setBorderPen()
Definition at line 457 of file qwt_plot_legenditem.cpp.
Change the font used for drawing the text label
Parameters
font Legend font
See also
font()
Definition at line 374 of file qwt_plot_legenditem.cpp.
Set the margin around each item
Parameters
margin Margin
See also
itemMargin(), setItemSpacing(), setMargin(), setSpacing()
Definition at line 319 of file qwt_plot_legenditem.cpp.
Set the spacing inside of each item
Parameters
spacing Spacing
See also
itemSpacing(), setItemMargin(), setMargin(), setSpacing()
Definition at line 346 of file qwt_plot_legenditem.cpp.
Set the margin around legend items. The default setting for the margin is 0.
Parameters
margin Margin in pixels
See also
margin(), setSpacing(), setItemMargin(), setItemSpacing
Definition at line 264 of file qwt_plot_legenditem.cpp.
Limit the number of columns. When aligning the legend horizontally ( Qt::AlignLeft, Qt::AlignRight ) the number of columns needs to be limited to avoid, that the width of the legend grows with an increasing number of entries.
Parameters
maxColumns Maximum number of columns. 0 means unlimited.
See also
maxColumns(), QwtDynGridLayout::setMaxColumns()
Definition at line 238 of file qwt_plot_legenditem.cpp.
Set the distance between the legend and the canvas border. The default setting is 10 pixels.
Parameters
orientations
Qt::Horizontal is for the left/right, Qt::Vertical for the
top/bottom offset.
numPixels Distance in pixels
See also
setMargin()
Definition at line 405 of file qwt_plot_legenditem.cpp.
Set the spacing between the legend items.
Parameters
spacing Spacing in pixels
See also
spacing(), setMargin()
Definition at line 294 of file qwt_plot_legenditem.cpp.
Set the pen for drawing text labels.
Parameters
pen Text pen
See also
textPen(), setFont()
Definition at line 561 of file qwt_plot_legenditem.cpp.
Returns
Spacing between the legend items
See also
setSpacing(), margin(), itemSpacing(), itemMargin()
Definition at line 308 of file qwt_plot_legenditem.cpp.
Returns
Pen for drawing text labels
See also
setTextPen(), font()
Definition at line 574 of file qwt_plot_legenditem.cpp.
Update the legend items according to modifications of a plot item
Parameters
plotItem Plot item
data Attributes of the legend entries
Reimplemented from QwtPlotItem.
Definition at line 697 of file qwt_plot_legenditem.cpp.
Generated automatically by Doxygen for Qwt User’s Guide from the source code.