QwtPlotLegendItem(3)
πΈ NAME πΈ
Okay bestie, welcome to the QwtPlotLegendItem(3) page from the Library Functions Manual. This class draws a legend inside the plot canvas β literally the canvas-legend main character. π
β¨ SYNOPSIS β¨
#include <qwt_plot_legenditem.h>
Inherits QwtPlotItem β yes, she's part of the plot-item family tree. π«Ά
π Public Types π
enum BackgroundMode { LegendBackground, ItemBackground }β background mode. The vibe selector for where the background goes.
π¦ Public Types inherited from QwtPlotItem π¦
enum RttiValuesβ runtime type information. The exact values are:
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 }
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 > ItemAttributestypedef QFlags< ItemInterest > ItemIntereststypedef QFlags< RenderHint > RenderHints
π Public Member Functions π
QwtPlotLegendItem ()β constructor.virtual ~QwtPlotLegendItem ()β destructor.virtual int rtti () const overrideβ runtime type info override.void setAlignmentInCanvas (Qt::Alignment)β set the alignment.Qt::Alignment alignmentInCanvas () constvoid setOffsetInCanvas (Qt::Orientations, int numPixels)β set the distance between the legend and the canvas border.int offsetInCanvas (Qt::Orientation) constvoid setMaxColumns (uint)β limit the number of columns.uint maxColumns () constvoid setMargin (int)β set the margin around legend items.int margin () constvoid setSpacing (int)β set the spacing between the legend items.int spacing () constvoid setItemMargin (int)int itemMargin () constvoid setItemSpacing (int)int itemSpacing () constvoid setFont (const QFont &)QFont font () constvoid setBorderRadius (double)double borderRadius () constvoid setBorderPen (const QPen &)QPen borderPen () constvoid setBackgroundBrush (const QBrush &)β set the background brush.QBrush backgroundBrush () constvoid setBackgroundMode (BackgroundMode)β set the background mode.BackgroundMode backgroundMode () constvoid setTextPen (const QPen &)β set the pen for drawing text labels.QPen textPen () constvirtual void draw (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const overridevoid clearLegend ()β remove all items from the legend.virtual void updateLegend (const QwtPlotItem *, const QList< QwtLegendData > &) overridevirtual QRect geometry (const QRectF &canvasRect) constvirtual QSize minimumSize (const QwtLegendData &) constvirtual int heightForWidth (const QwtLegendData &, int width) constQList< const QwtPlotItem * > plotItems () constQList< QRect > legendGeometries (const QwtPlotItem *) const
π Public Member Functions inherited from QwtPlotItem π
QwtPlotItem ()QwtPlotItem (const QString &title)QwtPlotItem (const QwtText &title)virtual ~QwtPlotItem ()β destroy theQwtPlotItem.void attach (QwtPlot *plot)β attach the item to a plot.void detach ()β detaches aQwtPlotItemfrom anyQwtPlotit has been associated with.QwtPlot * plot () constβ return attached plot.void setTitle (const QString &title)void setTitle (const QwtText &title)const QwtText & title () constvoid setItemAttribute (ItemAttribute, bool on=true)bool testItemAttribute (ItemAttribute) constvoid setItemInterest (ItemInterest, bool on=true)bool testItemInterest (ItemInterest) constvoid setRenderHint (RenderHint, bool on=true)bool testRenderHint (RenderHint) constvoid setRenderThreadCount (uint numThreads)uint renderThreadCount () constvoid setLegendIconSize (const QSize &)QSize legendIconSize () constdouble z () constvoid setZ (double z)β set the z value.void show ()β show the item.void hide ()β hide the item.virtual void setVisible (bool)bool isVisible () constvoid 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 () constvirtual 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
π§ Protected Member Functions π§
virtual void drawLegendData (QPainter *, const QwtPlotItem *, const QwtLegendData &, const QRectF &) constvirtual 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.
π Detailed Description π
Okay so QwtPlotLegendItem draws a legend inside the plot canvas. It can be used together with a QwtLegend or instead of it to have more space for the plot canvas. Slay for canvas real estate.
Unlike 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 on the plot canvas. The geometries of the legend items are available using legendGeometries(). iykyk
The legend item is aligned to the 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 of the plot canvas might be another option with a similar effect.
Definition at line 41 of file qwt_plot_legenditem.h.
π₯ Member Enumeration Documentation π₯
enum QwtPlotLegendItem::BackgroundMode
Background mode. Depending on the mode, the complete legend or each item might have a 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 & Destructor Documentation π
QwtPlotLegendItem::QwtPlotLegendItem () [explicit]
Constructor. Iconic.
Definition at line 175 of file qwt_plot_legenditem.cpp.
QwtPlotLegendItem::~QwtPlotLegendItem () [virtual]
Destructor. Cleanup queen.
Definition at line 185 of file qwt_plot_legenditem.cpp.
π Member Function Documentation π
Okay bestie, this is the function-by-function era β every getter, setter, draw hook and override, all accounted for. β¨
Qt::Alignment QwtPlotLegendItem::alignmentInCanvas () const
- Returns: Alignment flags
- See also:
setAlignmentInCanvas() - Definition: at line 223 of file
qwt_plot_legenditem.cpp.
QBrush QwtPlotLegendItem::backgroundBrush () const
- Returns: Brush is used to fill the background
- See also:
setBackgroundBrush(),backgroundMode(),drawBackground() - Definition: at line 522 of file
qwt_plot_legenditem.cpp.
QwtPlotLegendItem::BackgroundMode QwtPlotLegendItem::backgroundMode () const
- Returns:
backgroundMode - See also:
setBackgroundMode(),backgroundBrush(),drawBackground() - Definition: at line 550 of file
qwt_plot_legenditem.cpp.
QPen QwtPlotLegendItem::borderPen () const
- Returns: Pen for drawing the border
- See also:
setBorderPen(),backgroundBrush() - Definition: at line 496 of file
qwt_plot_legenditem.cpp.
double QwtPlotLegendItem::borderRadius () const
- Returns: Radius of the border
- See also:
setBorderRadius(),setBorderPen() - Definition: at line 472 of file
qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::clearLegend ()
- Remove all items from the legend.
- Definition: at line 759 of file
qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::draw (QPainter * painter, const QwtScaleMap & xMap, const QwtScaleMap & yMap, const QRectF & canvasRect) const [override], [virtual]
- Draw the legend
- Parameters:
painterβ PainterxMapβ x Scale MapyMapβ y Scale MapcanvasRectβ Contents rectangle of the canvas in painter coordinates
- Implements:
QwtPlotItem. - Definition: at line 587 of file
qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::drawBackground (QPainter * painter, const QRectF & rect) const [protected], [virtual]
- Draw a rounded rect
- Parameters:
painterβ Painterrectβ Bounding rectangle
- See also:
setBorderRadius(),setBorderPen(),setBackgroundBrush(),setBackgroundMode() - Definition: at line 630 of file
qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::drawLegendData (QPainter * painter, const QwtPlotItem * plotItem, const QwtLegendData & data, const QRectF & rect) const [protected], [virtual]
- Draw an entry on the legend
- Parameters:
painterβ Qt PainterplotItemβ Plot item, represented by the entrydataβ Attributes of the legend entryrectβ Bounding rectangle for the entry
- Definition: at line 780 of file
qwt_plot_legenditem.cpp.
QFont QwtPlotLegendItem::font () const
- Returns: Font used for drawing the text label
- See also:
setFont() - Definition: at line 389 of file
qwt_plot_legenditem.cpp.
QRect QwtPlotLegendItem::geometry (const QRectF & canvasRect) const [virtual]
- 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.
int QwtPlotLegendItem::heightForWidth (const QwtLegendData & data, int width) const [virtual]
- Returns: The preferred height, for a width.
- Parameters:
dataβ Attributes of the legend entrywidthβ Width
- Definition: at line 862 of file
qwt_plot_legenditem.cpp.
int QwtPlotLegendItem::itemMargin () const
- Returns: Margin around each item
- See also:
setItemMargin(),itemSpacing(),margin(),spacing() - Definition: at line 335 of file
qwt_plot_legenditem.cpp.
int QwtPlotLegendItem::itemSpacing () const
- Returns: Spacing inside of each item
- See also:
setItemSpacing(),itemMargin(),margin(),spacing() - Definition: at line 363 of file
qwt_plot_legenditem.cpp.
QList< QRect > QwtPlotLegendItem::legendGeometries (const QwtPlotItem * plotItem) const
- 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.
int QwtPlotLegendItem::margin () const
- Returns: Margin around the legend items
- See also:
setMargin(),spacing(),itemMargin(),itemSpacing() - Definition: at line 280 of file
qwt_plot_legenditem.cpp.
uint QwtPlotLegendItem::maxColumns () const
- Returns: Maximum number of columns
- See also:
maxColumns(),QwtDynGridLayout::maxColumns() - Definition: at line 251 of file
qwt_plot_legenditem.cpp.
QSize QwtPlotLegendItem::minimumSize (const QwtLegendData & data) const [virtual]
- 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.
int QwtPlotLegendItem::offsetInCanvas (Qt::Orientation orientation) const
- Parameters:
orientationβQt::Horizontalis for the left/right,Qt::Verticalfor 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.
QList< const QwtPlotItem * > QwtPlotLegendItem::plotItems () const
- 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.
int QwtPlotLegendItem::rtti () const [override], [virtual]
- Returns:
QwtPlotItem::Rtti_PlotLegend - Reimplemented from:
QwtPlotItem. - Definition: at line 192 of file
qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setAlignmentInCanvas (Qt::Alignment alignment)
- Set the alignment. 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.
void QwtPlotLegendItem::setBackgroundBrush (const QBrush & brush)
- 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.
void QwtPlotLegendItem::setBackgroundMode (BackgroundMode mode)
- 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.
void QwtPlotLegendItem::setBorderPen (const QPen & pen)
- 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.
void QwtPlotLegendItem::setBorderRadius (double radius)
- Set the radius for the border
- Parameters:
radiusβ A value<= 0defines a rectangular border
- See also:
borderRadius(),setBorderPen() - Definition: at line 457 of file
qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setFont (const QFont & font)
- 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.
void QwtPlotLegendItem::setItemMargin (int margin)
- 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.
void QwtPlotLegendItem::setItemSpacing (int spacing)
- 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.
void QwtPlotLegendItem::setMargin (int margin)
- 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.
void QwtPlotLegendItem::setMaxColumns (uint maxColumns)
- 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.0means unlimited.
- See also:
maxColumns(),QwtDynGridLayout::setMaxColumns() - Definition: at line 238 of file
qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setOffsetInCanvas (Qt::Orientations orientations, int numPixels)
- Set the distance between the legend and the canvas border. The default setting is
10pixels. - Parameters:
orientationsβQt::Horizontalis for the left/right,Qt::Verticalfor the top/bottom offset.numPixelsβ Distance in pixels
- See also:
setMargin() - Definition: at line 405 of file
qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setSpacing (int spacing)
- 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.
void QwtPlotLegendItem::setTextPen (const QPen & pen)
- 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.
int QwtPlotLegendItem::spacing () const
- Returns: Spacing between the legend items
- See also:
setSpacing(),margin(),itemSpacing(),itemMargin() - Definition: at line 308 of file
qwt_plot_legenditem.cpp.
QPen QwtPlotLegendItem::textPen () const
- Returns: Pen for drawing text labels
- See also:
setTextPen(),font() - Definition: at line 574 of file
qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::updateLegend (const QwtPlotItem * plotItem, const QList< QwtLegendData > & data) [override], [virtual]
- Update the legend items according to modifications of a plot item
- Parameters:
plotItemβ Plot itemdataβ Attributes of the legend entries
- Reimplemented from:
QwtPlotItem. - Definition: at line 697 of file
qwt_plot_legenditem.cpp.
π«Ά Author π«Ά
Generated automatically by Doxygen for Qwt User's Guide from the source code.
That's the whole member-function era, bestie π
β¨ Footer vibe: generated automatically by Doxygen for Qwt User's Guide from the source code, and the page is QwtPlotLegendItem(3) β no date in sight, just iconic Qwt energy ππ
π¦ where this page comes from
- alpine 3.24: qwt-doc 6.3.0-r0 Β· custom
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms