Qwt User's Guide 6.1.2

- Main Page
- Related Pages
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Functions Variables Typedefs Enumerations Enumerator Pages
Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions | List of all members
QwtLegend Class Reference

The legend widget. More...

`#include <qwt_legend.h>`

Inheritance diagram for QwtLegend:
[legend]

## Public Slots
virtual void | updateLegend (const QVariant &, const QList< QwtLegendData > &)
| Update the entries for an item. More...
Public Slots inherited from QwtAbstractLegend
virtual void | updateLegend (const QVariant &itemInfo, const QList< QwtLegendData > &data)=0
| Update the entries for a plot item. More...

## Signals
void | clicked (const QVariant &itemInfo, int index)
void | checked (const QVariant &itemInfo, bool on, int index)

## Public Member Functions
| QwtLegend (QWidget *parent=NULL)
virtual | ~QwtLegend ()
| Destructor.
void | setMaxColumns (uint numColums)
| Set the maximum number of entries in a row. More...
uint | maxColumns () const
void | setDefaultItemMode (QwtLegendData::Mode)
| Set the default mode for legend labels. More...
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 *)
virtual QSize | sizeHint () const
| Return a size hint.
virtual int | heightForWidth (int w) const
QScrollBar * | horizontalScrollBar () const
QScrollBar * | verticalScrollBar () const
virtual void | renderLegend (QPainter *, const QRectF &, bool fillBackground) const
virtual void | renderItem (QPainter *, const QWidget *, const QRectF &, bool fillBackground) const
virtual bool | isEmpty () const
virtual int | scrollExtent (Qt::Orientation) const
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. More...
virtual void | updateWidget (QWidget *widget, const QwtLegendData &data)
| Update the widget. More...

## 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

## Constructor & Destructor Documentation

QwtLegend::QwtLegend | ( | QWidget * | parent = `NULL` | ) |
| explicit

Constructor

Parameters

  parent | Parent widget

## Member Function Documentation

void QwtLegend::checked | ( | const QVariant & | itemInfo,
|  | bool | on,
|  | int | index
| ) |  |
| signal

A signal which is emitted when the user has clicked on a legend label, which is in QwtLegendData::Checkable mode

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

A signal which is emitted when the user has clicked on a legend label, which is in QwtLegendData::Clickable 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 | ( |  | ) |

The contents widget is the only child of the viewport of the internal QScrollArea and the parent widget of all legend items.

Returns
  Container widget of the legend items

const QWidget * QwtLegend::contentsWidget | ( |  | ) | const

The contents widget is the only child of the viewport of the internal QScrollArea and the parent widget of all legend items.

Returns
  Container widget of the legend items

QWidget * QwtLegend::createWidget | ( | const QwtLegendData & | data | ) | const
| protected virtual

Create a widget to be inserted into the legend.

The default implementation returns a QwtLegendLabel.

Parameters

  data | Attributes of the legend entry

Returns
  Widget representing data on the legend

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

QwtLegendData::Mode QwtLegend::defaultItemMode | ( |  | ) | const

Returns
  Default item mode

See Also
  setDefaultItemMode()

bool QwtLegend::eventFilter | ( | QObject * | object,
|  | QEvent * | event
| ) |  |
| virtual

Handle QEvent::ChildRemoved andQEvent::LayoutRequest events for the contentsWidget().

Parameters

  object | Object to be filtered
  event | Event

Returns
  Forwarded to QwtAbstractLegend::eventFilter()

int QwtLegend::heightForWidth | ( | int | width | ) | const
| virtual

Returns
  The preferred height, for a width.

Parameters

  width | Width

QScrollBar * QwtLegend::horizontalScrollBar | ( |  | ) | const

Returns
  Horizontal scrollbar

See Also
  verticalScrollBar()

bool QwtLegend::isEmpty | ( |  | ) | const
| virtual

Returns
  True, when no item is inserted

Implements QwtAbstractLegend.

void QwtLegend::itemChecked | ( | bool | on | ) |
| protected slot

Called internally when the legend has been checked Emits a checked() signal.

void QwtLegend::itemClicked | ( |  | ) |
| protected slot

Called internally when the legend has been clicked on. Emits a clicked() signal.

QVariant QwtLegend::itemInfo | ( | const QWidget * | widget | ) | const

Find the item that is associated to a widget

Parameters

  widget | Widget on the legend

Returns
  Associated item info

See Also
  legendWidget()

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

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()

uint QwtLegend::maxColumns | ( |  | ) | const

Returns
  Maximum number of entries in a row

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

void QwtLegend::renderItem | ( | QPainter * | painter,
|  | const QWidget * | widget,
|  | const QRectF & | rect,
|  | bool | fillBackground
| ) |  | const
| virtual

Render a legend entry into a given rectangle.

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

void QwtLegend::renderLegend | ( | QPainter * | painter,
|  | const QRectF & | rect,
|  | bool | fillBackground
| ) |  | const
| virtual

Render the legend into a given rectangle.

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.

int QwtLegend::scrollExtent | ( | Qt::Orientation | orientation | ) | const
| virtual

Return the extent, that is needed for the scrollbars

Parameters

  orientation | Orientation (

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

Reimplemented from QwtAbstractLegend.

void QwtLegend::setDefaultItemMode | ( | QwtLegendData::Mode | mode | ) |

Set the default mode for legend labels.

Legend labels will be constructed according to the attributes in a QwtLegendData object. When it doesn't contain a value for the QwtLegendData::ModeRole the label will be initialized with the default mode of the legend.

Parameters

  mode | Default item mode

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

Note
  Changing the mode doesn't have any effect on existing labels.

void QwtLegend::setMaxColumns | ( | uint | numColums | ) |

Set 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()

void QwtLegend::updateLegend | ( | const QVariant & | itemInfo,
|  | const QList< QwtLegendData > & | data
| ) |  |
| virtual slot

Update the entries for an item.

Parameters

  itemInfo | Info for an item
  data | List of legend entry attributes for the item

void QwtLegend::updateWidget | ( | QWidget * | widget,
|  | const QwtLegendData & | data
| ) |  |
| protected virtual

Update the widget.

Parameters

  widget | Usually a QwtLegendLabel
  data | Attributes to be displayed

See Also
  createWidget()

Note
  When widget is no QwtLegendLabel updateWidget() does nothing.

QScrollBar * QwtLegend::verticalScrollBar | ( |  | ) | const

Returns
  Vertical scrollbar

See Also
  horizontalScrollBar()