iCub-main
Loading...
Searching...
No Matches
Public Types | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
QCPLegend Class Reference

Manages a legend inside a QCustomPlot. More...

#include <qcustomplot.h>

+ Inheritance diagram for QCPLegend:

Public Types

enum  SelectablePart {
  spNone = 0x000 ,
  spLegendBox = 0x001 ,
  spItems = 0x002
}
 Defines the selectable parts of a legend. More...
 
- Public Types inherited from QCPLayoutElement
enum  UpdatePhase {
  upPreparation ,
  upMargins ,
  upLayout
}
 Defines the phases of the update process, that happens just before a replot. More...
 

Signals

void selectionChanged (QCPLegend::SelectableParts parts)
 This signal is emitted when the selection state of this legend has changed.
 
void selectableChanged (QCPLegend::SelectableParts parts)
 
- Signals inherited from QCPLayerable
void layerChanged (QCPLayer *newLayer)
 This signal is emitted when the layer of this layerable changes, i.e.
 

Public Member Functions

 QCPLegend ()
 Constructs a new QCPLegend instance with parentPlot as the containing plot and default values.
 
virtual ~QCPLegend ()
 
QPen borderPen () const
 
QBrush brush () const
 
QFont font () const
 
QColor textColor () const
 
QSize iconSize () const
 
int iconTextPadding () const
 
QPen iconBorderPen () const
 
SelectableParts selectableParts () const
 
SelectableParts selectedParts () const
 
QPen selectedBorderPen () const
 
QPen selectedIconBorderPen () const
 
QBrush selectedBrush () const
 
QFont selectedFont () const
 
QColor selectedTextColor () const
 
void setBorderPen (const QPen &pen)
 Sets the pen, the border of the entire legend is drawn with.
 
void setBrush (const QBrush &brush)
 Sets the brush of the legend background.
 
void setFont (const QFont &font)
 Sets the default font of legend text.
 
void setTextColor (const QColor &color)
 Sets the default color of legend text.
 
void setIconSize (const QSize &size)
 Sets the size of legend icons.
 
void setIconSize (int width, int height)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void setIconTextPadding (int padding)
 Sets the horizontal space in pixels between the legend icon and the text next to it.
 
void setIconBorderPen (const QPen &pen)
 Sets the pen used to draw a border around each legend icon.
 
Q_SLOT void setSelectableParts (const SelectableParts &selectableParts)
 Sets whether the user can (de-)select the parts in selectable by clicking on the QCustomPlot surface.
 
Q_SLOT void setSelectedParts (const SelectableParts &selectedParts)
 Sets the selected state of the respective legend parts described by SelectablePart.
 
void setSelectedBorderPen (const QPen &pen)
 When the legend box is selected, this pen is used to draw the border instead of the normal pen set via setBorderPen.
 
void setSelectedIconBorderPen (const QPen &pen)
 Sets the pen legend items will use to draw their icon borders, when they are selected.
 
void setSelectedBrush (const QBrush &brush)
 When the legend box is selected, this brush is used to draw the legend background instead of the normal brush set via setBrush.
 
void setSelectedFont (const QFont &font)
 Sets the default font that is used by legend items when they are selected.
 
void setSelectedTextColor (const QColor &color)
 Sets the default text color that is used by legend items when they are selected.
 
virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const
 Layout elements are sensitive to events inside their outer rect.
 
QCPAbstractLegendItemitem (int index) const
 Returns the item with index i.
 
QCPPlottableLegendItemitemWithPlottable (const QCPAbstractPlottable *plottable) const
 Returns the QCPPlottableLegendItem which is associated with plottable (e.g.
 
int itemCount () const
 Returns the number of items currently in the legend.
 
bool hasItem (QCPAbstractLegendItem *item) const
 Returns whether the legend contains itm.
 
bool hasItemWithPlottable (const QCPAbstractPlottable *plottable) const
 Returns whether the legend contains a QCPPlottableLegendItem which is associated with plottable (e.g.
 
bool addItem (QCPAbstractLegendItem *item)
 Adds item to the legend, if it's not present already.
 
bool removeItem (int index)
 Removes the item with index index from the legend.
 
bool removeItem (QCPAbstractLegendItem *item)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes item from the legend.
 
void clearItems ()
 Removes all items from the legend.
 
QList< QCPAbstractLegendItem * > selectedItems () const
 Returns the legend items that are currently selected.
 
- Public Member Functions inherited from QCPLayoutGrid
 QCPLayoutGrid ()
 Creates an instance of QCPLayoutGrid and sets default values.
 
virtual ~QCPLayoutGrid ()
 
int rowCount () const
 Returns the number of rows in the layout.
 
int columnCount () const
 Returns the number of columns in the layout.
 
QList< double > columnStretchFactors () const
 
QList< double > rowStretchFactors () const
 
int columnSpacing () const
 
int rowSpacing () const
 
void setColumnStretchFactor (int column, double factor)
 Sets the stretch factor of column.
 
void setColumnStretchFactors (const QList< double > &factors)
 Sets the stretch factors of all columns.
 
void setRowStretchFactor (int row, double factor)
 Sets the stretch factor of row.
 
void setRowStretchFactors (const QList< double > &factors)
 Sets the stretch factors of all rows.
 
void setColumnSpacing (int pixels)
 Sets the gap that is left blank between columns to pixels.
 
void setRowSpacing (int pixels)
 Sets the gap that is left blank between rows to pixels.
 
virtual void updateLayout ()
 
virtual int elementCount () const
 Returns the number of elements/cells in the layout.
 
virtual QCPLayoutElementelementAt (int index) const
 Returns the element in the cell with the given index.
 
virtual QCPLayoutElementtakeAt (int index)
 Removes the element with the given index from the layout and returns it.
 
virtual bool take (QCPLayoutElement *element)
 Removes the specified element from the layout and returns true on success.
 
virtual QList< QCPLayoutElement * > elements (bool recursive) const
 Returns a list of all child elements in this layout element.
 
virtual void simplify ()
 Simplifies the layout by collapsing rows and columns which only contain empty cells.
 
virtual QSize minimumSizeHint () const
 Returns the minimum size this layout element (the inner rect) may be compressed to.
 
virtual QSize maximumSizeHint () const
 Returns the maximum size this layout element (the inner rect) may be expanded to.
 
QCPLayoutElementelement (int row, int column) const
 Returns the element in the cell in row and column.
 
bool addElement (int row, int column, QCPLayoutElement *element)
 Adds the element to cell with row and column.
 
bool hasElement (int row, int column)
 Returns whether the cell at row and column exists and contains a valid element, i.e.
 
void expandTo (int newRowCount, int newColumnCount)
 Expands the layout to have newRowCount rows and newColumnCount columns.
 
void insertRow (int newIndex)
 Inserts a new row with empty cells at the row index newIndex.
 
void insertColumn (int newIndex)
 Inserts a new column with empty cells at the column index newIndex.
 
- Public Member Functions inherited from QCPLayout
 QCPLayout ()
 Creates an instance of QCPLayout and sets default values.
 
virtual void update (UpdatePhase phase)
 First calls the QCPLayoutElement::update base class implementation to update the margins on this layout.
 
bool removeAt (int index)
 Removes and deletes the element at the provided index.
 
bool remove (QCPLayoutElement *element)
 Removes and deletes the provided element.
 
void clear ()
 Removes and deletes all layout elements in this layout.
 
- Public Member Functions inherited from QCPLayoutElement
 QCPLayoutElement (QCustomPlot *parentPlot=0)
 Creates an instance of QCPLayoutElement and sets default values.
 
virtual ~QCPLayoutElement ()
 
QCPLayoutlayout () const
 Returns the parent layout of this layout element.
 
QRect rect () const
 Returns the inner rect of this layout element.
 
QRect outerRect () const
 
QMargins margins () const
 
QMargins minimumMargins () const
 
QCP::MarginSides autoMargins () const
 
QSize minimumSize () const
 
QSize maximumSize () const
 
QCPMarginGroupmarginGroup (QCP::MarginSide side) const
 
QHash< QCP::MarginSide, QCPMarginGroup * > marginGroups () const
 
void setOuterRect (const QRect &rect)
 Sets the outer rect of this layout element.
 
void setMargins (const QMargins &margins)
 Sets the margins of this layout element.
 
void setMinimumMargins (const QMargins &margins)
 If setAutoMargins is enabled on some or all margins, this function is used to provide minimum values for those margins.
 
void setAutoMargins (QCP::MarginSides sides)
 Sets on which sides the margin shall be calculated automatically.
 
void setMinimumSize (const QSize &size)
 Sets the minimum size for the inner rect of this layout element.
 
void setMinimumSize (int width, int height)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the minimum size for the inner rect of this layout element.
 
void setMaximumSize (const QSize &size)
 Sets the maximum size for the inner rect of this layout element.
 
void setMaximumSize (int width, int height)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the maximum size for the inner rect of this layout element.
 
void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group)
 Sets the margin group of the specified margin sides.
 
- Public Member Functions inherited from QCPLayerable
 QCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0)
 Creates a new QCPLayerable instance.
 
 ~QCPLayerable ()
 
bool visible () const
 
QCustomPlotparentPlot () const
 
QCPLayerableparentLayerable () const
 Returns the parent layerable of this layerable.
 
QCPLayerlayer () const
 
bool antialiased () const
 
void setVisible (bool on)
 Sets the visibility of this layerable object.
 
Q_SLOT bool setLayer (QCPLayer *layer)
 Sets the layer of this layerable object.
 
bool setLayer (const QString &layerName)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the layer of this layerable object by name.
 
void setAntialiased (bool enabled)
 Sets whether this object will be drawn antialiased or not.
 
bool realVisibility () const
 Returns whether this layerable is visible, taking the visibility of the layerable parent and the visibility of the layer this layerable is on into account.
 

Protected Member Functions

virtual void parentPlotInitialized (QCustomPlot *parentPlot)
 
virtual QCP::Interaction selectionCategory () const
 
virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
 
virtual void draw (QCPPainter *painter)
 
virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
 
virtual void deselectEvent (bool *selectionStateChanged)
 
QPen getBorderPen () const
 
QBrush getBrush () const
 
- Protected Member Functions inherited from QCPLayoutGrid
void getMinimumRowColSizes (QVector< int > *minColWidths, QVector< int > *minRowHeights) const
 
void getMaximumRowColSizes (QVector< int > *maxColWidths, QVector< int > *maxRowHeights) const
 
- Protected Member Functions inherited from QCPLayout
void sizeConstraintsChanged () const
 Subclasses call this method to report changed (minimum/maximum) size constraints.
 
void adoptElement (QCPLayoutElement *el)
 
void releaseElement (QCPLayoutElement *el)
 
QVector< int > getSectionSizes (QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const
 
- Protected Member Functions inherited from QCPLayoutElement
virtual int calculateAutoMargin (QCP::MarginSide side)
 
virtual void mousePressEvent (QMouseEvent *event)
 This event is called, if the mouse was pressed while being inside the outer rect of this layout element.
 
virtual void mouseMoveEvent (QMouseEvent *event)
 This event is called, if the mouse is moved inside the outer rect of this layout element.
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 This event is called, if the mouse was previously pressed inside the outer rect of this layout element and is now released.
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 This event is called, if the mouse is double-clicked inside the outer rect of this layout element.
 
virtual void wheelEvent (QWheelEvent *event)
 This event is called, if the mouse wheel is scrolled while the cursor is inside the rect of this layout element.
 
- Protected Member Functions inherited from QCPLayerable
virtual QRect clipRect () const
 
void initializeParentPlot (QCustomPlot *parentPlot)
 
void setParentLayerable (QCPLayerable *parentLayerable)
 
bool moveToLayer (QCPLayer *layer, bool prepend)
 
void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
 

Protected Attributes

QPen mBorderPen
 
QPen mIconBorderPen
 
QBrush mBrush
 
QFont mFont
 
QColor mTextColor
 
QSize mIconSize
 
int mIconTextPadding
 
SelectableParts mSelectedParts
 
SelectableParts mSelectableParts
 
QPen mSelectedBorderPen
 
QPen mSelectedIconBorderPen
 
QBrush mSelectedBrush
 
QFont mSelectedFont
 
QColor mSelectedTextColor
 
- Protected Attributes inherited from QCPLayoutGrid
QList< QList< QCPLayoutElement * > > mElements
 
QList< double > mColumnStretchFactors
 
QList< double > mRowStretchFactors
 
int mColumnSpacing
 
int mRowSpacing
 
- Protected Attributes inherited from QCPLayoutElement
QCPLayoutmParentLayout
 
QSize mMinimumSize
 
QSize mMaximumSize
 
QRect mRect
 
QRect mOuterRect
 
QMargins mMargins
 
QMargins mMinimumMargins
 
QCP::MarginSides mAutoMargins
 
QHash< QCP::MarginSide, QCPMarginGroup * > mMarginGroups
 
- Protected Attributes inherited from QCPLayerable
bool mVisible
 
QCustomPlotmParentPlot
 
QPointer< QCPLayerablemParentLayerable
 
QCPLayermLayer
 
bool mAntialiased
 

Friends

class QCustomPlot
 
class QCPAbstractLegendItem
 

Detailed Description

Manages a legend inside a QCustomPlot.

A legend is a small box somewhere in the plot which lists plottables with their name and icon.

Normally, the legend is populated by calling QCPAbstractPlottable::addToLegend. The respective legend item can be removed with QCPAbstractPlottable::removeFromLegend. However, QCPLegend also offers an interface to add and manipulate legend items directly: item, itemWithPlottable, itemCount, addItem, removeItem, etc.

The QCPLegend derives from QCPLayoutGrid and as such can be placed in any position a QCPLayoutElement may be positioned. The legend items are themselves QCPLayoutElements which are placed in the grid layout of the legend. QCPLegend only adds an interface specialized for handling child elements of type QCPAbstractLegendItem, as mentioned above. In principle, any other layout elements may also be added to a legend via the normal QCPLayoutGrid interface. However, the QCPAbstractLegendItem-Interface will ignore those elements (e.g. itemCount will only return the number of items with QCPAbstractLegendItems type).

By default, every QCustomPlot has one legend (QCustomPlot::legend) which is placed in the inset layout of the main axis rect (QCPAxisRect::insetLayout). To move the legend to another position inside the axis rect, use the methods of the QCPLayoutInset. To move the legend outside of the axis rect, place it anywhere else with the QCPLayout/QCPLayoutElement interface.

Definition at line 2145 of file qcustomplot.h.

Member Enumeration Documentation

◆ SelectablePart

Defines the selectable parts of a legend.

See also
setSelectedParts, setSelectableParts
Enumerator
spNone 

0x000 None

spLegendBox 

0x001 The legend box (frame)

spItems 

0x002 Legend items individually (see selectedItems)

Definition at line 2170 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPLegend()

QCPLegend::QCPLegend ( )
explicit

Constructs a new QCPLegend instance with parentPlot as the containing plot and default values.

Note that by default, QCustomPlot already contains a legend ready to be used as QCustomPlot::legend

Definition at line 12964 of file qcustomplot.cpp.

◆ ~QCPLegend()

QCPLegend::~QCPLegend ( )
virtual

Definition at line 12987 of file qcustomplot.cpp.

Member Function Documentation

◆ addItem()

bool QCPLegend::addItem ( QCPAbstractLegendItem item)

Adds item to the legend, if it's not present already.

Returns true on sucess, i.e. if the item wasn't in the list already and has been successfuly added.

The legend takes ownership of the item.

Definition at line 13305 of file qcustomplot.cpp.

◆ applyDefaultAntialiasingHint()

void QCPLegend::applyDefaultAntialiasingHint ( QCPPainter painter) const
protectedvirtual

Reimplemented from QCPLayoutElement.

Definition at line 13389 of file qcustomplot.cpp.

◆ borderPen()

QPen QCPLegend::borderPen ( ) const
inline

Definition at line 2181 of file qcustomplot.h.

◆ brush()

QBrush QCPLegend::brush ( ) const
inline

Definition at line 2182 of file qcustomplot.h.

◆ clearItems()

void QCPLegend::clearItems ( )

Removes all items from the legend.

Definition at line 13350 of file qcustomplot.cpp.

◆ deselectEvent()

void QCPLegend::deselectEvent ( bool *  selectionStateChanged)
protectedvirtual

Reimplemented from QCPLayerable.

Definition at line 13457 of file qcustomplot.cpp.

◆ draw()

void QCPLegend::draw ( QCPPainter painter)
protectedvirtual

Reimplemented from QCPLayoutElement.

Definition at line 13419 of file qcustomplot.cpp.

◆ font()

QFont QCPLegend::font ( ) const
inline

Definition at line 2183 of file qcustomplot.h.

◆ getBorderPen()

QPen QCPLegend::getBorderPen ( ) const
protected

Definition at line 13399 of file qcustomplot.cpp.

◆ getBrush()

QBrush QCPLegend::getBrush ( ) const
protected

Definition at line 13409 of file qcustomplot.cpp.

◆ hasItem()

bool QCPLegend::hasItem ( QCPAbstractLegendItem item) const

Returns whether the legend contains itm.

Definition at line 13277 of file qcustomplot.cpp.

◆ hasItemWithPlottable()

bool QCPLegend::hasItemWithPlottable ( const QCPAbstractPlottable plottable) const

Returns whether the legend contains a QCPPlottableLegendItem which is associated with plottable (e.g.

a QCPGraph*). If such an item isn't in the legend, returns false.

See also
itemWithPlottable

Definition at line 13293 of file qcustomplot.cpp.

◆ iconBorderPen()

QPen QCPLegend::iconBorderPen ( ) const
inline

Definition at line 2187 of file qcustomplot.h.

◆ iconSize()

QSize QCPLegend::iconSize ( ) const
inline

Definition at line 2185 of file qcustomplot.h.

◆ iconTextPadding()

int QCPLegend::iconTextPadding ( ) const
inline

Definition at line 2186 of file qcustomplot.h.

◆ item()

QCPAbstractLegendItem * QCPLegend::item ( int  index) const

Returns the item with index i.

See also
itemCount

Definition at line 13241 of file qcustomplot.cpp.

◆ itemCount()

int QCPLegend::itemCount ( ) const

Returns the number of items currently in the legend.

See also
item

Definition at line 13269 of file qcustomplot.cpp.

◆ itemWithPlottable()

QCPPlottableLegendItem * QCPLegend::itemWithPlottable ( const QCPAbstractPlottable plottable) const

Returns the QCPPlottableLegendItem which is associated with plottable (e.g.

a QCPGraph*). If such an item isn't in the legend, returns 0.

See also
hasItemWithPlottable

Definition at line 13252 of file qcustomplot.cpp.

◆ parentPlotInitialized()

void QCPLegend::parentPlotInitialized ( QCustomPlot parentPlot)
protectedvirtual

Reimplemented from QCPLayoutElement.

Definition at line 13482 of file qcustomplot.cpp.

◆ removeItem() [1/2]

bool QCPLegend::removeItem ( int  index)

Removes the item with index index from the legend.

Returns true, if successful.

See also
itemCount, clearItems

Definition at line 13321 of file qcustomplot.cpp.

◆ removeItem() [2/2]

bool QCPLegend::removeItem ( QCPAbstractLegendItem item)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes item from the legend.

Returns true, if successful.

See also
clearItems

Definition at line 13340 of file qcustomplot.cpp.

◆ selectableChanged

void QCPLegend::selectableChanged ( QCPLegend::SelectableParts  parts)
signal

◆ selectableParts()

SelectableParts QCPLegend::selectableParts ( ) const
inline

Definition at line 2188 of file qcustomplot.h.

◆ selectedBorderPen()

QPen QCPLegend::selectedBorderPen ( ) const
inline

Definition at line 2190 of file qcustomplot.h.

◆ selectedBrush()

QBrush QCPLegend::selectedBrush ( ) const
inline

Definition at line 2192 of file qcustomplot.h.

◆ selectedFont()

QFont QCPLegend::selectedFont ( ) const
inline

Definition at line 2193 of file qcustomplot.h.

◆ selectedIconBorderPen()

QPen QCPLegend::selectedIconBorderPen ( ) const
inline

Definition at line 2191 of file qcustomplot.h.

◆ selectedItems()

QList< QCPAbstractLegendItem * > QCPLegend::selectedItems ( ) const

Returns the legend items that are currently selected.

If no items are selected, the list is empty.

See also
QCPAbstractLegendItem::setSelected, setSelectable

Definition at line 13362 of file qcustomplot.cpp.

◆ selectedParts()

QCPLegend::SelectableParts QCPLegend::selectedParts ( ) const

Definition at line 12995 of file qcustomplot.cpp.

◆ selectedTextColor()

QColor QCPLegend::selectedTextColor ( ) const
inline

Definition at line 2194 of file qcustomplot.h.

◆ selectEvent()

void QCPLegend::selectEvent ( QMouseEvent *  event,
bool  additive,
const QVariant &  details,
bool *  selectionStateChanged 
)
protectedvirtual

Reimplemented from QCPLayerable.

Definition at line 13443 of file qcustomplot.cpp.

◆ selectionCategory()

QCP::Interaction QCPLegend::selectionCategory ( ) const
protectedvirtual

Reimplemented from QCPLayerable.

Definition at line 13470 of file qcustomplot.cpp.

◆ selectionChanged

void QCPLegend::selectionChanged ( QCPLegend::SelectableParts  selection)
signal

This signal is emitted when the selection state of this legend has changed.

See also
setSelectedParts, setSelectableParts

◆ selectTest()

double QCPLegend::selectTest ( const QPointF &  pos,
bool  onlySelectable,
QVariant *  details = 0 
) const
virtual

Layout elements are sensitive to events inside their outer rect.

If pos is within the outer rect, this method returns a value corresponding to 0.99 times the parent plot's selection tolerance. However, layout elements are not selectable by default. So if onlySelectable is true, -1.0 is returned.

See QCPLayerable::selectTest for a general explanation of this virtual method.

QCPLayoutElement subclasses may reimplement this method to provide more specific selection test behaviour.

Reimplemented from QCPLayoutElement.

Definition at line 13428 of file qcustomplot.cpp.

◆ setBorderPen()

void QCPLegend::setBorderPen ( const QPen &  pen)

Sets the pen, the border of the entire legend is drawn with.

Definition at line 13016 of file qcustomplot.cpp.

◆ setBrush()

void QCPLegend::setBrush ( const QBrush &  brush)

Sets the brush of the legend background.

Definition at line 13024 of file qcustomplot.cpp.

◆ setFont()

void QCPLegend::setFont ( const QFont &  font)

Sets the default font of legend text.

Legend items that draw text (e.g. the name of a graph) will use this font by default. However, a different font can be specified on a per-item-basis by accessing the specific legend item.

This function will also set font on all already existing legend items.

See also
QCPAbstractLegendItem::setFont

Definition at line 13038 of file qcustomplot.cpp.

◆ setIconBorderPen()

void QCPLegend::setIconBorderPen ( const QPen &  pen)

Sets the pen used to draw a border around each legend icon.

Legend items that draw an icon (e.g. a visual representation of the graph) will use this pen by default.

If no border is wanted, set this to Qt::NoPen.

Definition at line 13100 of file qcustomplot.cpp.

◆ setIconSize() [1/2]

void QCPLegend::setIconSize ( const QSize &  size)

Sets the size of legend icons.

Legend items that draw an icon (e.g. a visual representation of the graph) will use this size by default.

Definition at line 13071 of file qcustomplot.cpp.

◆ setIconSize() [2/2]

void QCPLegend::setIconSize ( int  width,
int  height 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 13078 of file qcustomplot.cpp.

◆ setIconTextPadding()

void QCPLegend::setIconTextPadding ( int  padding)

Sets the horizontal space in pixels between the legend icon and the text next to it.

Legend items that draw an icon (e.g. a visual representation of the graph) and text (e.g. the name of the graph) will use this space by default.

Definition at line 13089 of file qcustomplot.cpp.

◆ setSelectableParts()

void QCPLegend::setSelectableParts ( const SelectableParts &  selectable)

Sets whether the user can (de-)select the parts in selectable by clicking on the QCustomPlot surface.

(When QCustomPlot::setInteractions contains QCP::iSelectLegend.)

However, even when selectable is set to a value not allowing the selection of a specific part, it is still possible to set the selection of this part manually, by calling setSelectedParts directly.

See also
SelectablePart, setSelectedParts

Definition at line 13115 of file qcustomplot.cpp.

◆ setSelectedBorderPen()

void QCPLegend::setSelectedBorderPen ( const QPen &  pen)

When the legend box is selected, this pen is used to draw the border instead of the normal pen set via setBorderPen.

See also
setSelectedParts, setSelectableParts, setSelectedBrush

Definition at line 13176 of file qcustomplot.cpp.

◆ setSelectedBrush()

void QCPLegend::setSelectedBrush ( const QBrush &  brush)

When the legend box is selected, this brush is used to draw the legend background instead of the normal brush set via setBrush.

See also
setSelectedParts, setSelectableParts, setSelectedBorderPen

Definition at line 13197 of file qcustomplot.cpp.

◆ setSelectedFont()

void QCPLegend::setSelectedFont ( const QFont &  font)

Sets the default font that is used by legend items when they are selected.

This function will also set font on all already existing legend items.

See also
setFont, QCPAbstractLegendItem::setSelectedFont

Definition at line 13209 of file qcustomplot.cpp.

◆ setSelectedIconBorderPen()

void QCPLegend::setSelectedIconBorderPen ( const QPen &  pen)

Sets the pen legend items will use to draw their icon borders, when they are selected.

See also
setSelectedParts, setSelectableParts, setSelectedFont

Definition at line 13186 of file qcustomplot.cpp.

◆ setSelectedParts()

void QCPLegend::setSelectedParts ( const SelectableParts &  selected)

Sets the selected state of the respective legend parts described by SelectablePart.

When a part is selected, it uses a different pen/font and brush. If some legend items are selected and selected doesn't contain spItems, those items become deselected.

The entire selection mechanism is handled automatically when QCustomPlot::setInteractions contains iSelectLegend. You only need to call this function when you wish to change the selection state manually.

This function can change the selection state of a part even when setSelectableParts was set to a value that actually excludes the part.

emits the selectionChanged signal when selected is different from the previous selection state.

Note that it doesn't make sense to set the selected state spItems here when it wasn't set before, because there's no way to specify which exact items to newly select. Do this by calling QCPAbstractLegendItem::setSelected directly on the legend item you wish to select.

See also
SelectablePart, setSelectableParts, selectTest, setSelectedBorderPen, setSelectedIconBorderPen, setSelectedBrush, setSelectedFont

Definition at line 13145 of file qcustomplot.cpp.

◆ setSelectedTextColor()

void QCPLegend::setSelectedTextColor ( const QColor &  color)

Sets the default text color that is used by legend items when they are selected.

This function will also set color on all already existing legend items.

See also
setTextColor, QCPAbstractLegendItem::setSelectedTextColor

Definition at line 13226 of file qcustomplot.cpp.

◆ setTextColor()

void QCPLegend::setTextColor ( const QColor &  color)

Sets the default color of legend text.

Legend items that draw text (e.g. the name of a graph) will use this color by default. However, a different colors can be specified on a per-item-basis by accessing the specific legend item.

This function will also set color on all already existing legend items.

See also
QCPAbstractLegendItem::setTextColor

Definition at line 13057 of file qcustomplot.cpp.

◆ textColor()

QColor QCPLegend::textColor ( ) const
inline

Definition at line 2184 of file qcustomplot.h.

Friends And Related Symbol Documentation

◆ QCPAbstractLegendItem

friend class QCPAbstractLegendItem
friend

Definition at line 2263 of file qcustomplot.h.

◆ QCustomPlot

friend class QCustomPlot
friend

Definition at line 2262 of file qcustomplot.h.

Member Data Documentation

◆ mBorderPen

QPen QCPLegend::mBorderPen
protected

Definition at line 2234 of file qcustomplot.h.

◆ mBrush

QBrush QCPLegend::mBrush
protected

Definition at line 2235 of file qcustomplot.h.

◆ mFont

QFont QCPLegend::mFont
protected

Definition at line 2236 of file qcustomplot.h.

◆ mIconBorderPen

QPen QCPLegend::mIconBorderPen
protected

Definition at line 2234 of file qcustomplot.h.

◆ mIconSize

QSize QCPLegend::mIconSize
protected

Definition at line 2238 of file qcustomplot.h.

◆ mIconTextPadding

int QCPLegend::mIconTextPadding
protected

Definition at line 2239 of file qcustomplot.h.

◆ mSelectableParts

SelectableParts QCPLegend::mSelectableParts
protected

Definition at line 2240 of file qcustomplot.h.

◆ mSelectedBorderPen

QPen QCPLegend::mSelectedBorderPen
protected

Definition at line 2241 of file qcustomplot.h.

◆ mSelectedBrush

QBrush QCPLegend::mSelectedBrush
protected

Definition at line 2242 of file qcustomplot.h.

◆ mSelectedFont

QFont QCPLegend::mSelectedFont
protected

Definition at line 2243 of file qcustomplot.h.

◆ mSelectedIconBorderPen

QPen QCPLegend::mSelectedIconBorderPen
protected

Definition at line 2241 of file qcustomplot.h.

◆ mSelectedParts

SelectableParts QCPLegend::mSelectedParts
protected

Definition at line 2240 of file qcustomplot.h.

◆ mSelectedTextColor

QColor QCPLegend::mSelectedTextColor
protected

Definition at line 2244 of file qcustomplot.h.

◆ mTextColor

QColor QCPLegend::mTextColor
protected

Definition at line 2237 of file qcustomplot.h.


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