QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
QwtLegendData Class Reference

Attributes of an entry on a legend. More...

#include <qwt_legend_data.h>

Public Types

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

Public Member Functions

 QwtLegendData ()
 Constructor.
 
 QwtLegendData (const QwtLegendData &)
 Copy constructor.
 
 QwtLegendData (QwtLegendData &&) noexcept=default
 
 ~QwtLegendData ()
 Destructor.
 
QwtLegendDataoperator= (const QwtLegendData &)
 Copy assignment.
 
QwtLegendDataoperator= (QwtLegendData &&) noexcept=default
 
void setValues (const QMap< int, QVariant > &)
 Set the legend attributes.
 
const QMap< int, QVariant > & values () const
 Return the legend attributes.
 
void setValue (int role, const QVariant &)
 Set an attribute value.
 
QVariant value (int role) const
 Return the attribute value for a specific role.
 
bool hasRole (int role) const
 Check if a value exists for a specific role.
 
bool isValid () const
 Check if the legend data is valid.
 
QwtGraphic icon () const
 Return the icon.
 
QwtText title () const
 Return the title.
 
Mode mode () const
 Return the mode.
 

Detailed Description

Attributes of an entry on a legend.

QwtLegendData is an abstract container (like QAbstractModel) to exchange attributes that are only known between 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
Note
The stockchart example implements a legend as a tree with checkable items

Member Enumeration Documentation

◆ Mode

Mode defining how a legend entry interacts.

Enumerator
ReadOnly 

The legend item is not interactive, like a label.

Clickable 

The legend item is clickable, like a push button.

Checkable 

The legend item is checkable, like a checkable button.

◆ Role

Identifier how to interpret a QVariant.

Enumerator
ModeRole 

The value is a Mode.

TitleRole 

The value is a title.

IconRole 

The value is an icon.

UserRole 

Values < UserRole are reserved for internal use.

Member Function Documentation

◆ hasRole()

bool QwtLegendData::hasRole ( int  role) const

Check if a value exists for a specific role.

Parameters
roleAttribute role
Returns
True, when the internal map has an entry for role
See also
setValue(), value()

◆ icon()

QwtGraphic QwtLegendData::icon ( ) const

Return the icon.

Returns
Value of the IconRole attribute
See also
title(), mode()

◆ isValid()

bool QwtLegendData::isValid ( ) const

Check if the legend data is valid.

Returns
True, when the internal map is empty
See also
setValues(), setValue()

◆ mode()

QwtLegendData::Mode QwtLegendData::mode ( ) const

Return the mode.

Returns
Value of the ModeRole attribute
ReadOnly when no mode is set
See also
title(), icon()

◆ setValue()

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

Set an attribute value.

Parameters
roleAttribute role
dataAttribute value
See also
value()

◆ setValues()

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

Set the legend attributes.

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

Parameters
mapValues
See also
values()

◆ title()

QwtText QwtLegendData::title ( ) const

Return the title.

Returns
Value of the TitleRole attribute
See also
icon(), mode()

◆ value()

QVariant QwtLegendData::value ( int  role) const

Return the attribute value for a specific role.

Parameters
roleAttribute role
Returns
Attribute value for a specific role
See also
setValue()

◆ values()

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

Return the legend attributes.

Returns
Legend attributes
See also
setValues()

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