Main Page · Class Overview · Hierarchy · All Classes
Public Functions | Signals | Protected Functions
QCPAbstractLegendItem Class Reference

The abstract base class for all items in a QCPLegend. More...

Inheritance diagram for QCPAbstractLegendItem:
Inheritance graph

Public Functions

 QCPAbstractLegendItem (QCPLegend *parent)
bool antialiased () const
QFont font () const
QColor textColor () const
QFont selectedFont () const
QColor selectedTextColor () const
bool selectable () const
bool selected () const
void setAntialiased (bool enabled)
void setFont (const QFont &font)
void setTextColor (const QColor &color)
void setSelectedFont (const QFont &font)
void setSelectedTextColor (const QColor &color)
void setSelectable (bool selectable)
void setSelected (bool selected)

Signals

void selectionChanged (bool selected)

Protected Functions

virtual void draw (QCPPainter *painter, const QRect &rect) const =0
virtual QSize size (const QSize &targetSize) const =0
void applyAntialiasingHint (QCPPainter *painter) const

Detailed Description

The abstract base class for all items in a QCPLegend.

It defines a very basic interface to items in a QCPLegend. For representing plottables in the legend, the subclass QCPPlottableLegendItem is more suitable.

Only derive directly from this class when you need absolute freedom (i.e. a legend item that's not associated with a plottable).

You must implement the following pure virtual functions:

You inherit the following members you may use:

QCPLegend *mParentLegend A pointer to the parent QCPLegend.
QFont mFont The generic font of the item. You should use this font for all or at least the most prominent text of the item.

Constructor & Destructor Documentation

Constructs a QCPAbstractLegendItem and associates it with the QCPLegend parent. This does not cause the item to be added to parent, so QCPLegend::addItem must be called separately.


Member Function Documentation

void QCPAbstractLegendItem::setAntialiased ( bool  enabled)

Sets whether this legend item is drawn antialiased or not.

Note that this setting may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.

void QCPAbstractLegendItem::setFont ( const QFont &  font)

Sets the default font of this specific legend item to font.

See also:
setTextColor, QCPLegend::setFont
void QCPAbstractLegendItem::setTextColor ( const QColor &  color)

Sets the default text color of this specific legend item to color.

See also:
setFont, QCPLegend::setTextColor
void QCPAbstractLegendItem::setSelectedFont ( const QFont &  font)

When this legend item is selected, font is used to draw generic text, instead of the normal font set with setFont.

See also:
setFont, QCPLegend::setSelectedFont
void QCPAbstractLegendItem::setSelectedTextColor ( const QColor &  color)

When this legend item is selected, color is used to draw generic text, instead of the normal color set with setTextColor.

See also:
setTextColor, QCPLegend::setSelectedTextColor
void QCPAbstractLegendItem::setSelectable ( bool  selectable)

Sets whether this specific legend item is selectable.

See also:
setSelected, QCustomPlot::setInteractions
void QCPAbstractLegendItem::setSelected ( bool  selected)

Sets whether this specific legend item is selected. The selection state of the parent QCPLegend is updated correspondingly.

It is possible to set the selection state of this item by calling this function directly, even if setSelectable is set to false.

See also:
setSelectable, QCustomPlot::setInteractions
void QCPAbstractLegendItem::selectionChanged ( bool  selected) [signal]

This signal is emitted when the selection state of this legend item has changed, either by user interaction or by a direct call to setSelected.

void QCPAbstractLegendItem::draw ( QCPPainter painter,
const QRect &  rect 
) const [protected, pure virtual]

Draws this legend item with painter inside the specified rect. The rect typically has the size which was returned from a preceding size call.

Implemented in QCPPlottableLegendItem.

QSize QCPAbstractLegendItem::size ( const QSize &  targetSize) const [protected, pure virtual]

Returns the size this item occupies in the legend. The legend will adapt its layout with the help of this function. If this legend item can have a variable width (e.g. auto-wrapping text), this function tries to find a size with a width close to the width of targetSize. The height of targetSize only may have meaning in specific sublasses. Typically, it's ignored.

Implemented in QCPPlottableLegendItem.

void QCPAbstractLegendItem::applyAntialiasingHint ( QCPPainter painter) const [protected]

Sets the QPainter::Antialiasing render hint on the provided painter, depending on the setAntialiased state of this legend item as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.


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