Scroll to navigation

QwtLegendData(3) Qwt User's Guide QwtLegendData(3)


QwtLegendData - Attributes of an entry on a legend.


#include <qwt_legend_data.h>

Public Types

enum Mode { ReadOnly, Clickable, Checkable }
Mode defining how a legend entry interacts. enum Role { ModeRole, TitleRole, IconRole, UserRole = 32 }
Identifier how to interpret a QVariant.

Public Member Functions

QwtLegendData ()
Constructor. ~QwtLegendData ()
Destructor. void setValues (const QMap< int, QVariant > &)
const QMap< int, QVariant > & values () const
void setValue (int role, const QVariant &)
QVariant value (int role) const
bool hasRole (int role) const
bool isValid () const
QwtGraphic icon () const
QwtText title () const
Mode mode () const

Detailed Description

Attributes of an entry on a legend.

QwtLegendData is an abstract container ( like QAbstractModel ) to exchange attributes, that are only known between to the plot item and the legend.

By overloading QwtPlotItem::legendData() any other set of attributes could be used, that can be handled by a modified ( or completely different ) implementation of a legend.

See also

QwtLegend, QwtPlotLegendItem


The stockchart example implements a legend as a tree with checkable items

Definition at line 36 of file qwt_legend_data.h.

Member Enumeration Documentation

enum QwtLegendData::Mode

Mode defining how a legend entry interacts.


The legend item is not interactive, like a label.
The legend item is clickable, like a push button.
The legend item is checkable, like a checkable button.

Definition at line 40 of file qwt_legend_data.h.

Member Function Documentation

bool QwtLegendData::hasRole (int role) const


role Attribute role


True, when the internal map has an entry for role

Definition at line 51 of file qwt_legend_data.cpp.

QwtGraphic QwtLegendData::icon () const


Value of the IconRole attribute

Definition at line 106 of file qwt_legend_data.cpp.

bool QwtLegendData::isValid () const


True, when the internal map is empty

Definition at line 82 of file qwt_legend_data.cpp.

QwtLegendData::Mode QwtLegendData::mode () const


Value of the ModeRole attribute

Definition at line 120 of file qwt_legend_data.cpp.

void QwtLegendData::setValue (int role, const QVariant & data)

Set an attribute value


role Attribute role
data Attribute value

See also


Definition at line 64 of file qwt_legend_data.cpp.

void QwtLegendData::setValues (const QMap< int, QVariant > & map)

Set the legend attributes

QwtLegendData actually is a QMap<int, QVariant> with some convenience interfaces


map Values

See also


Definition at line 33 of file qwt_legend_data.cpp.

QwtText QwtLegendData::title () const


Value of the TitleRole attribute

Definition at line 88 of file qwt_legend_data.cpp.

QVariant QwtLegendData::value (int role) const


role Attribute role


Attribute value for a specific role

Definition at line 73 of file qwt_legend_data.cpp.

const QMap< int, QVariant > & QwtLegendData::values () const


Legend attributes

See also


Definition at line 42 of file qwt_legend_data.cpp.


Generated automatically by Doxygen for Qwt User's Guide from the source code.

Sun Jul 18 2021 Version 6.2.0