QwtLegend(3)

🌸 NAME 🌸

okay bestie, you found the QwtLegend(3) page from the Library Functions Manual β€” welcome to the legend widget era. QwtLegend - The legend widget. πŸ’…βœ¨

✨ SYNOPSIS ✨

Include it like this, exactly:

#include <qwt_legend.h>

It inherits QwtAbstractLegend. 🫢

πŸ’… Public Slots πŸ’…

  • virtual void updateLegend (const QVariant &, const QList< QwtLegendData > &) override β€” Update the entries for an item.

🌈 Public Slots inherited from QwtAbstractLegend 🌈

  • virtual void updateLegend (const QVariant &itemInfo, const QList< QwtLegendData > &data)=0 β€” Update the entries for a plot item.

πŸŽ€ Signals πŸŽ€

  • void clicked (const QVariant &itemInfo, int index)
  • void checked (const QVariant &itemInfo, bool on, int index)

No descriptions on these signal lines in the page β€” just the declarations. πŸ“‘

πŸ¦‹ Public Member Functions πŸ¦‹

  • QwtLegend (QWidget *parent=NULL)
  • virtual ~QwtLegend () β€” Destructor.
  • void setMaxColumns (uint numColums) β€” Set the maximum number of entries in a row.
  • uint maxColumns () const
  • void setDefaultItemMode (QwtLegendData::Mode) β€” Set the default mode for legend labels.
  • QwtLegendData::Mode defaultItemMode () const
  • QWidget * contentsWidget ()
  • const QWidget * contentsWidget () const
  • QWidget * legendWidget (const QVariant &) const
  • QList< QWidget * > legendWidgets (const QVariant &) const
  • QVariant itemInfo (const QWidget *) const
  • virtual bool eventFilter (QObject *, QEvent *) override
  • virtual QSize sizeHint () const override β€” Return a size hint.
  • virtual int heightForWidth (int w) const override
  • QScrollBar * horizontalScrollBar () const
  • QScrollBar * verticalScrollBar () const
  • virtual void renderLegend (QPainter *, const QRectF &, bool fillBackground) const override
  • virtual void renderItem (QPainter *, const QWidget *, const QRectF &, bool fillBackground) const
  • virtual bool isEmpty () const override
  • virtual int scrollExtent (Qt::Orientation) const override

🌟 Public Member Functions inherited from QwtAbstractLegend 🌟

  • QwtAbstractLegend (QWidget *parent=NULL)
  • virtual ~QwtAbstractLegend () β€” Destructor.

πŸ’œ Protected Slots πŸ’œ

  • void itemClicked ()
  • void itemChecked (bool)

πŸ“ Protected Member Functions πŸ“

  • virtual QWidget * createWidget (const QwtLegendData &) const β€” Create a widget to be inserted into the legend.
  • virtual void updateWidget (QWidget *, const QwtLegendData &) β€” Update the widget.

πŸ’– Detailed Description πŸ’–

The legend widget. 😌

The QwtLegend widget is a tabular arrangement of legend items. Legend items might be any type of widget, but in general they will be a QwtLegendLabel. 🧚

πŸ‘€ See also πŸ‘€

  • QwtLegendLabel
  • QwtPlotItem
  • QwtPlot

Definition at line 31 of file qwt_legend.h. πŸ“Œ

🧚 Constructor & Destructor Documentation 🧚

πŸ’– QwtLegend::QwtLegend (QWidget * parent = NULL) [explicit] πŸ’–

Constructor. πŸ› οΈ

Parameters

  • parent β€” Parent widget

Definition at line 258 of file qwt_legend.cpp. πŸ“Œ

πŸ’– QwtLegend::~QwtLegend () [virtual] πŸ’–

Destructor. πŸŒ™

Definition at line 281 of file qwt_legend.cpp. πŸ“Œ

πŸ’… Member Function Documentation πŸ’…

okay bestie, deep breath β€” this is the full roster, every single member function, no skips, no "you can read the rest yourself" energy. 🫢 Some of these are signals, some are protected hooks you can override, some are just lil getters. All of them matter. Let's go. ✨


🌸 void QwtLegend::checked (const QVariant & itemInfo, bool on, int index) β€” [signal] 🌸

This is the signal that fires when the user clicks a legend label that's living in QwtLegendData::Checkable mode. It's literally announcing "bestie checked a box" πŸ’–

Parameters

  • itemInfo β€” info for the item of the selected legend label
  • index β€” index of the legend label in the list of widgets that are associated with the plot item
  • on β€” true when the legend label is checked
Note: clicks are disabled as default πŸ™ˆ

See also: setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo()


πŸ¦‹ void QwtLegend::clicked (const QVariant & itemInfo, int index) β€” [signal] πŸ¦‹

The other signal, the tap-happy one: it's emitted when the user has clicked on a legend label that's sitting in QwtLegendData::Clickable mode. Same vibe, different mode. πŸ‘‘

Parameters

  • itemInfo β€” info for the item item of the selected legend item
  • index β€” index of the legend label in the list of widgets that are associated with the plot item
Note: clicks are disabled as default πŸ™ˆ

See also: setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo()


πŸŽ€ QWidget * QwtLegend::contentsWidget () πŸŽ€

Okay so picture this: the contents widget is the only child of the viewport of the internal QScrollArea, and it's also the parent widget of all the legend items. It's giving main character energy, holding everything together. 🌈

Returns: container widget of the legend items

Definition at line 355 of file qwt_legend.cpp.


πŸ’œ const QWidget * QwtLegend::contentsWidget () const πŸ’œ

Same iconic widget as above, just the const version β€” and yep, same story: it's the only child of the viewport of the internal QScrollArea and the parent of all the legend items. 🫢

Returns: container widget of the legend items

Definition at line 385 of file qwt_legend.cpp.


✨ QWidget * QwtLegend::createWidget (const QwtLegendData & legendData) const β€” [protected], [virtual] ✨

This is the "make me a widget to put in the legend" function. The default implementation just returns a QwtLegendLabel β€” simple, effective, slay. πŸ’…

Parameters

  • legendData β€” attributes of the legend entry

Returns: widget representing data on the legend

Note: updateWidget() will called soon after createWidget() with the same attributes.

Definition at line 467 of file qwt_legend.cpp.


πŸ“ QwtLegendData::Mode QwtLegend::defaultItemMode () const πŸ“

Returns: default item mode

See also: setDefaultItemMode()

Definition at line 344 of file qwt_legend.cpp.


🧚 bool QwtLegend::eventFilter (QObject * object, QEvent * event) β€” [override], [virtual] 🧚

This one handles the QEvent::ChildRemoved and QEvent::LayoutRequest events for the contentsWidget(). Somebody's gotta keep the group chat in order. 😭

Parameters

  • object β€” object to be filtered
  • event β€” event

Returns: forwarded to QwtAbstractLegend::eventFilter()

Definition at line 559 of file qwt_legend.cpp.


🌺 int QwtLegend::heightForWidth (int width) const β€” [override], [virtual] 🌺

Returns: the preferred height, for a width.

Parameters

  • width β€” width

Definition at line 538 of file qwt_legend.cpp.


⭐ QScrollBar * QwtLegend::horizontalScrollBar () const ⭐

Returns: horizontal scrollbar

See also: verticalScrollBar()

Definition at line 364 of file qwt_legend.cpp.


πŸ’€ bool QwtLegend::isEmpty () const β€” [override], [virtual] πŸ’€

Returns: true, when no item is inserted

Implements QwtAbstractLegend.

Definition at line 810 of file qwt_legend.cpp.


🌈 void QwtLegend::itemChecked (bool on) β€” [protected], [slot] 🌈

Called internally when the legend has been checked. Emits a checked() signal. That's the whole job bestie. 🫑

Definition at line 638 of file qwt_legend.cpp.


πŸŽ€ void QwtLegend::itemClicked () β€” [protected], [slot] πŸŽ€

Called internally when the legend has been clicked on. Emits a clicked() signal. Yes that's literally it. πŸ’–

Definition at line 616 of file qwt_legend.cpp.


πŸ”₯ QVariant QwtLegend::itemInfo (const QWidget * widget) const πŸ”₯

Finds the item that's associated with a widget. Detective mode: activated. πŸ•΅οΈβ€β™€οΈ

Parameters

  • widget β€” widget on the legend

Returns: associated item info

See also: legendWidget()

Definition at line 804 of file qwt_legend.cpp.


πŸ‘‘ QWidget * QwtLegend::legendWidget (const QVariant & itemInfo) const πŸ‘‘

Returns: first widget in the list of widgets associated to an item

Parameters

  • itemInfo β€” info about an item

See also: itemInfo(), QwtPlot::itemToInfo()

Note: almost all types of items have only one widget

Definition at line 788 of file qwt_legend.cpp.


πŸ¦‹ QList< QWidget * > QwtLegend::legendWidgets (const QVariant & itemInfo) const πŸ¦‹

Returns: list of widgets associated to a item

Parameters

  • itemInfo β€” info about an item

See also: legendWidget(), itemInfo(), QwtPlot::itemToInfo()

Definition at line 777 of file qwt_legend.cpp.


🌸 uint QwtLegend::maxColumns () const 🌸

Returns: maximum number of entries in a row

See also: setMaxColumns(), QwtDynGridLayout::maxColumns()

Definition at line 310 of file qwt_legend.cpp.


✨ void QwtLegend::renderItem (QPainter * painter, const QWidget * widget, const QRectF & rect, bool fillBackground) const β€” [virtual] ✨

Renders a single legend entry into a given rectangle. It's giving arts and crafts hour. 🎨

Parameters

  • painter β€” painter
  • widget β€” widget representing a legend entry
  • rect β€” bounding rectangle
  • fillBackground β€” when true, fill rect with the widget background
Note: when widget is not derived from QwtLegendLabel, renderItem does nothing beside the background

Definition at line 727 of file qwt_legend.cpp.


πŸ’œ void QwtLegend::renderLegend (QPainter * painter, const QRectF & rect, bool fillBackground) const β€” [override], [virtual] πŸ’œ

Renders the whole legend into a given rectangle β€” the group photo of functions. πŸ“Έ

Parameters

  • painter β€” painter
  • rect β€” bounding rectangle
  • fillBackground β€” when true, fill rect with the widget background

See also: renderLegend() is used by QwtPlotRenderer β€” not by QwtLegend itself

Implements QwtAbstractLegend.

Definition at line 665 of file qwt_legend.cpp.


🧚 int QwtLegend::scrollExtent (Qt::Orientation orientation) const β€” [override], [virtual] 🧚

Returns the extent, that is needed for the scrollbars. Lowkey very specific but okay. πŸ’…

Parameters

  • orientation β€” orientation

Returns: the width of the vertical scrollbar for Qt::Horizontal and v.v.

Reimplemented from QwtAbstractLegend.

Definition at line 821 of file qwt_legend.cpp.


πŸ“ void QwtLegend::setDefaultItemMode (QwtLegendData::Mode mode) πŸ“

Sets the default mode for legend labels. Here's the tea: legend labels get constructed according to the attributes in a QwtLegendData object, and when that object doesn't contain a value for the QwtLegendData::ModeRole, the label gets initialized with the legend's default mode. ✨

Parameters

  • mode β€” default item mode

See also: itemMode(), QwtLegendData::value(), QwtPlotItem::legendData()

Note: changing the mode doesn't have any effect on existing labels. New labels only, no take-backs. 😭

Definition at line 335 of file qwt_legend.cpp.


🌺 void QwtLegend::setMaxColumns (uint numColums) 🌺

Sets the maximum number of entries in a row. F.e when the maximum is set to 1 all items are aligned vertically. 0 means unlimited. πŸ™Œ

Parameters

  • numColums β€” maximum number of entries in a row

See also: maxColumns(), QwtDynGridLayout::setMaxColumns()

Definition at line 296 of file qwt_legend.cpp.


⭐ QSize QwtLegend::sizeHint () const β€” [override], [virtual] ⭐

Returns a size hint. Short and sweet, we love a minimal queen. πŸ‘‘

Definition at line 526 of file qwt_legend.cpp.


🌈 void QwtLegend::updateLegend (const QVariant & itemInfo, const QList< QwtLegendData > & legendData) β€” [override], [virtual], [slot] 🌈

Updates the entries for an item. Glow-up time for the legend. πŸ’…

Parameters

  • itemInfo β€” info for an item
  • legendData β€” list of legend entry attributes for the item

Definition at line 396 of file qwt_legend.cpp.


πŸŽ€ void QwtLegend::updateWidget (QWidget * widget, const QwtLegendData & legendData) β€” [protected], [virtual] πŸŽ€

Updates the widget. The little sibling of createWidget(). 🫢

Parameters

  • widget β€” usually a QwtLegendLabel
  • legendData β€” attributes to be displayed

See also: createWidget()

Note: when widget is no QwtLegendLabel, updateWidget() does nothing.

Definition at line 489 of file qwt_legend.cpp.


πŸ’– QScrollBar * QwtLegend::verticalScrollBar () const πŸ’–

Returns: vertical scrollbar

See also: horizontalScrollBar()

Definition at line 373 of file qwt_legend.cpp.


πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for Qwt User's Guide from the source code. Not me hand-typing it, the robots did that part. πŸ€–πŸ’…


okay that's the whole page bestie, you made it to the end, I'm so proud of you πŸ₯ΉπŸ’– This edition is from the Qwt User's Guide, the QwtLegend(3) page, and it's auto-generated by Doxygen straight from the source code β€” so if anything here looks off, blame the source, not me. periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from