QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
Loading...
Searching...
No Matches
Classes | 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:
QwtAbstractLegend

Classes

class  PrivateData
 

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
 

Signals

void clicked (const QVariant &itemInfo, int index)
 Signal emitted when the user clicks on a legend label in Clickable mode.
 
void checked (const QVariant &itemInfo, bool on, int index)
 Signal emitted when the user clicks on a legend label in Checkable mode.
 

Public Member Functions

 QwtLegend (QWidget *parent=nullptr)
 Constructor for QwtLegend.
 
void setMaxColumns (uint numColums)
 Set the maximum number of entries in a row.
 
uint maxColumns () const
 Return the maximum number of entries in a row.
 
void setDefaultItemMode (QwtLegendData::Mode)
 Set the default mode for legend labels.
 
QwtLegendData::Mode defaultItemMode () const
 Return the default item mode.
 
QWidget * contentsWidget ()
 Return the contents widget.
 
const QWidget * contentsWidget () const
 Return the contents widget (const version)
 
QWidget * legendWidget (const QVariant &) const
 Return first widget in the list of widgets associated to an item.
 
QList< QWidget * > legendWidgets (const QVariant &) const
 Return list of widgets associated to an item.
 
QVariant itemInfo (const QWidget *) const
 Find the item that is associated to a widget.
 
virtual bool eventFilter (QObject *, QEvent *) override
 Handle QEvent::ChildRemoved and QEvent::LayoutRequest events.
 
virtual QSize sizeHint () const override
 Return a size hint.
 
virtual int heightForWidth (int w) const override
 Return the preferred height for a given width.
 
QScrollBar * horizontalScrollBar () const
 Return the horizontal scrollbar.
 
QScrollBar * verticalScrollBar () const
 Return the vertical scrollbar.
 
virtual void renderLegend (QPainter *, const QRectF &, bool fillBackground) const override
 Render the legend into a given rectangle.
 
virtual void renderItem (QPainter *, const QWidget *, const QRectF &, bool fillBackground) const
 Render a legend entry into a given rectangle.
 
virtual bool isEmpty () const override
 Check if the legend is empty.
 
virtual int scrollExtent (Qt::Orientation) const override
 Return the extent that is needed for the scrollbars.
 
- Public Member Functions inherited from QwtAbstractLegend
 QwtAbstractLegend (QWidget *parent=nullptr)
 Constructor for QwtAbstractLegend.
 
 ~QwtAbstractLegend () override
 Destructor for QwtAbstractLegend.
 

Protected Slots

void itemClicked ()
 Called internally when the legend has been clicked on.
 
void itemChecked (bool)
 Called internally when the legend has been checked.
 

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

Constructor & Destructor Documentation

◆ QwtLegend()

QwtLegend::QwtLegend ( QWidget *  parent = nullptr)
explicit

Constructor for QwtLegend.

Parameters
parentParent widget

Destructor

Member Function Documentation

◆ checked

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

Signal emitted when the user clicks on a legend label in Checkable mode.

Parameters
itemInfoInfo for the item of the selected legend label
onTrue when the legend label is checked
indexIndex of the legend label in the list of widgets associated with the plot item
Note
Clicks are disabled as default
See also
setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo()

◆ clicked

void QwtLegend::clicked ( const QVariant &  itemInfo,
int  index 
)
signal

Signal emitted when the user clicks on a legend label in Clickable mode.

Parameters
itemInfoInfo for the item of the selected legend item
indexIndex of the legend label in the list of widgets associated with the plot item
Note
Clicks are disabled as default
See also
setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo()

◆ contentsWidget() [1/2]

QWidget * QwtLegend::contentsWidget ( )

Return the contents widget.

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

◆ contentsWidget() [2/2]

const QWidget * QwtLegend::contentsWidget ( ) const

Return the contents widget (const version)

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

◆ createWidget()

QWidget * QwtLegend::createWidget ( const QwtLegendData legendData) const
protectedvirtual

Create a widget to be inserted into the legend.

The default implementation returns a QwtLegendLabel.

Parameters
legendDataAttributes of the legend entry
Returns
Widget representing data on the legend
Note
updateWidget() will called soon after createWidget() with the same attributes.
See also
updateWidget()

◆ defaultItemMode()

QwtLegendData::Mode QwtLegend::defaultItemMode ( ) const

Return the default item mode.

Returns
Default item mode
See also
setDefaultItemMode()

◆ eventFilter()

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

Handle QEvent::ChildRemoved and QEvent::LayoutRequest events.

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

Parameters
objectObject to be filtered
eventEvent
Returns
Forwarded to QwtAbstractLegend::eventFilter()

◆ heightForWidth()

int QwtLegend::heightForWidth ( int  width) const
overridevirtual

Return the preferred height for a given width.

Parameters
widthWidth
Returns
Preferred height
See also
sizeHint()

◆ horizontalScrollBar()

QScrollBar * QwtLegend::horizontalScrollBar ( ) const

Return the horizontal scrollbar.

Returns
Horizontal scrollbar
See also
verticalScrollBar()

◆ isEmpty()

bool QwtLegend::isEmpty ( ) const
overridevirtual

Check if the legend is empty.

Returns
True, when no item is inserted

Implements QwtAbstractLegend.

◆ itemChecked

void QwtLegend::itemChecked ( bool  on)
protectedslot

Called internally when the legend has been checked.

Emits a checked() signal.

See also
checked(), itemClicked()

◆ itemClicked

void QwtLegend::itemClicked ( )
protectedslot

Called internally when the legend has been clicked on.

Emits a clicked() signal.

See also
clicked(), itemChecked()

◆ itemInfo()

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

Find the item that is associated to a widget.

Parameters
widgetWidget on the legend
Returns
Associated item info
See also
legendWidget()

◆ legendWidget()

QWidget * QwtLegend::legendWidget ( const QVariant &  itemInfo) const

Return first widget in the list of widgets associated to an item.

Parameters
itemInfoInfo about an item
Returns
First widget in the list of widgets associated to an item
See also
itemInfo(), QwtPlot::itemToInfo()
Note
Almost all types of items have only one widget

◆ legendWidgets()

QList< QWidget * > QwtLegend::legendWidgets ( const QVariant &  itemInfo) const

Return list of widgets associated to an item.

Parameters
itemInfoInfo about an item
Returns
List of widgets associated to an item
See also
legendWidget(), itemInfo(), QwtPlot::itemToInfo()

◆ maxColumns()

uint QwtLegend::maxColumns ( ) const

Return the maximum number of entries in a row.

Returns
Maximum number of entries in a row
See also
setMaxColumns(), QwtDynGridLayout::maxColumns()

◆ renderItem()

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

Render a legend entry into a given rectangle.

Parameters
painterPainter
widgetWidget representing a legend entry
rectBounding rectangle
fillBackgroundWhen true, fill rect with the widget background
Note
When widget is not derived from QwtLegendLabel renderItem does nothing beside the background

◆ renderLegend()

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

Render the legend into a given rectangle.

Parameters
painterPainter
rectBounding rectangle
fillBackgroundWhen true, fill rect with the widget background
See also
renderLegend() is used by QwtPlotRenderer - not by QwtLegend itself

Implements QwtAbstractLegend.

◆ scrollExtent()

int QwtLegend::scrollExtent ( Qt::Orientation  orientation) const
overridevirtual

Return the extent that is needed for the scrollbars.

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

Reimplemented from QwtAbstractLegend.

◆ setDefaultItemMode()

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
modeDefault item mode
See also
itemMode(), QwtLegendData::value(), QwtPlotItem::legendData()
Note
Changing the mode doesn't have any effect on existing labels.

◆ setMaxColumns()

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
numColumsMaximum number of entries in a row
See also
maxColumns(), QwtDynGridLayout::setMaxColumns()

◆ sizeHint()

QSize QwtLegend::sizeHint ( ) const
overridevirtual

Return a size hint.

Returns
Size hint
See also
heightForWidth()

◆ updateLegend

void QwtLegend::updateLegend ( const QVariant &  itemInfo,
const QList< QwtLegendData > &  legendData 
)
overridevirtualslot

Update the entries for an item.

Parameters
itemInfoInfo for an item
legendDataList of legend entry attributes for the item
See also
updateWidget(), createWidget()

◆ updateWidget()

void QwtLegend::updateWidget ( QWidget *  widget,
const QwtLegendData legendData 
)
protectedvirtual

Update the widget.

Parameters
widgetUsually a QwtLegendLabel
legendDataAttributes to be displayed
See also
createWidget()
Note
When widget is no QwtLegendLabel updateWidget() does nothing.

◆ verticalScrollBar()

QScrollBar * QwtLegend::verticalScrollBar ( ) const

Return the vertical scrollbar.

Returns
Vertical scrollbar
See also
horizontalScrollBar()

The documentation for this class was generated from the following files: