QCPAbstractLegendItem

Search for usage in LXR

Inheritance diagram for QCPAbstractLegendItem:

Signals

void selectableChanged (bool selectable)
 
void selectionChanged (bool selected)
 
- Signals inherited from QCPLayerable
void layerChanged (QCPLayer *newLayer)
 

Public Member Functions

 QCPAbstractLegendItem (QCPLegend *parent)
 
QFont font () const
 
QCPLegendparentLegend () const
 
bool selectable () const
 
bool selected () const
 
QFont selectedFont () const
 
QColor selectedTextColor () const
 
virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const override
 
void setFont (const QFont &font)
 
Q_SLOT void setSelectable (bool selectable)
 
Q_SLOT void setSelected (bool selected)
 
void setSelectedFont (const QFont &font)
 
void setSelectedTextColor (const QColor &color)
 
void setTextColor (const QColor &color)
 
QColor textColor () const
 
- Public Member Functions inherited from QCPLayoutElement
 QCPLayoutElement (QCustomPlot *parentPlot=nullptr)
 
QCP::MarginSides autoMargins () const
 
virtual QList< QCPLayoutElement * > elements (bool recursive) const
 
QCPLayoutlayout () const
 
QCPMarginGroupmarginGroup (QCP::MarginSide side) const
 
QHash< QCP::MarginSide, QCPMarginGroup * > marginGroups () const
 
QMargins margins () const
 
virtual QSize maximumOuterSizeHint () const
 
QSize maximumSize () const
 
QMargins minimumMargins () const
 
virtual QSize minimumOuterSizeHint () const
 
QSize minimumSize () const
 
QRect outerRect () const
 
QRect rect () const
 
void setAutoMargins (QCP::MarginSides sides)
 
void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group)
 
void setMargins (const QMargins &margins)
 
void setMaximumSize (const QSize &size)
 
void setMaximumSize (int width, int height)
 
void setMinimumMargins (const QMargins &margins)
 
void setMinimumSize (const QSize &size)
 
void setMinimumSize (int width, int height)
 
void setOuterRect (const QRect &rect)
 
void setSizeConstraintRect (SizeConstraintRect constraintRect)
 
SizeConstraintRect sizeConstraintRect () const
 
virtual void update (UpdatePhase phase)
 
- Public Member Functions inherited from QCPLayerable
 QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=nullptr)
 
bool antialiased () const
 
QCPLayerlayer () const
 
QCPLayerableparentLayerable () const
 
QCustomPlotparentPlot () const
 
bool realVisibility () const
 
void setAntialiased (bool enabled)
 
bool setLayer (const QString &layerName)
 
Q_SLOT bool setLayer (QCPLayer *layer)
 
void setVisible (bool on)
 
bool visible () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Protected Member Functions

virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const override
 
virtual QRect clipRect () const override
 
virtual void deselectEvent (bool *selectionStateChanged) override
 
virtual void draw (QCPPainter *painter) override=0
 
virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) override
 
virtual QCP::Interaction selectionCategory () const override
 
- Protected Member Functions inherited from QCPLayoutElement
virtual int calculateAutoMargin (QCP::MarginSide side)
 
virtual void layoutChanged ()
 
virtual void parentPlotInitialized (QCustomPlot *parentPlot) override
 
- Protected Member Functions inherited from QCPLayerable
void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
 
void initializeParentPlot (QCustomPlot *parentPlot)
 
virtual void mouseDoubleClickEvent (QMouseEvent *event, const QVariant &details)
 
virtual void mouseMoveEvent (QMouseEvent *event, const QPointF &startPos)
 
virtual void mousePressEvent (QMouseEvent *event, const QVariant &details)
 
virtual void mouseReleaseEvent (QMouseEvent *event, const QPointF &startPos)
 
bool moveToLayer (QCPLayer *layer, bool prepend)
 
void setParentLayerable (QCPLayerable *parentLayerable)
 
virtual void wheelEvent (QWheelEvent *event)
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Protected Attributes

QFont mFont
 
QCPLegendmParentLegend
 
bool mSelectable
 
bool mSelected
 
QFont mSelectedFont
 
QColor mSelectedTextColor
 
QColor mTextColor
 
- Protected Attributes inherited from QCPLayoutElement
QCP::MarginSides mAutoMargins
 
QHash< QCP::MarginSide, QCPMarginGroup * > mMarginGroups
 
QMargins mMargins
 
QSize mMaximumSize
 
QMargins mMinimumMargins
 
QSize mMinimumSize
 
QRect mOuterRect
 
QCPLayoutmParentLayout
 
QRect mRect
 
SizeConstraintRect mSizeConstraintRect
 
- Protected Attributes inherited from QCPLayerable
bool mAntialiased
 
QCPLayermLayer
 
QPointer< QCPLayerablemParentLayerable
 
QCustomPlotmParentPlot
 
bool mVisible
 

Additional Inherited Members

- Public Types inherited from QCPLayoutElement
enum  SizeConstraintRect { scrInnerRect , scrOuterRect }
 
enum  UpdatePhase { upPreparation , upMargins , upLayout }
 
- Public Types inherited from QObject
typedef  QObjectList
 
- Properties inherited from QObject
 objectName
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 

Detailed Description

The abstract base class for all entries in a QCPLegend.

It defines a very basic interface for entries 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 (e.g. a custom legend entry that's not even 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.

Definition at line 5050 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPAbstractLegendItem()

QCPAbstractLegendItem::QCPAbstractLegendItem ( QCPLegend * parent)
explicit

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.

Definition at line 18754 of file qcustomplot.cpp.

Member Function Documentation

◆ applyDefaultAntialiasingHint()

void QCPAbstractLegendItem::applyDefaultAntialiasingHint ( QCPPainter * painter) const
overrideprotectedvirtual

This function applies the default antialiasing setting to the specified painter, using the function applyAntialiasingHint. It is the antialiasing state the painter is put in, when draw is called on the layerable. If the layerable has multiple entities whose antialiasing setting may be specified individually, this function should set the antialiasing state of the most prominent entity. In this case however, the draw function usually calls the specialized versions of this function before drawing each entity, effectively overriding the setting of the default antialiasing hint.

First example: QCPGraph has multiple entities that have an antialiasing setting: The graph line, fills and scatters. Those can be configured via QCPGraph::setAntialiased, QCPGraph::setAntialiasedFill and QCPGraph::setAntialiasedScatters. Consequently, there isn't only the QCPGraph::applyDefaultAntialiasingHint function (which corresponds to the graph line's antialiasing), but specialized ones like QCPGraph::applyFillAntialiasingHint and QCPGraph::applyScattersAntialiasingHint. So before drawing one of those entities, QCPGraph::draw calls the respective specialized applyAntialiasingHint function.

Second example: QCPItemLine consists only of a line so there is only one antialiasing setting which can be controlled with QCPItemLine::setAntialiased. (This function is inherited by all layerables. The specialized functions, as seen on QCPGraph, must be added explicitly to the respective layerable subclass.) Consequently it only has the normal QCPItemLine::applyDefaultAntialiasingHint. The QCPItemLine::draw function doesn't need to care about setting any antialiasing states, because the default antialiasing hint is already set on the painter when the draw function is called, and that's the state it wants to draw the line with.

Reimplemented from QCPLayoutElement.

Definition at line 18856 of file qcustomplot.cpp.

◆ clipRect()

QRect QCPAbstractLegendItem::clipRect ( ) const
overrideprotectedvirtual

Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.

The returned clipping rect is set on the painter before the draw function of the respective object is called.

Reimplemented from QCPLayerable.

Definition at line 18862 of file qcustomplot.cpp.

◆ deselectEvent()

void QCPAbstractLegendItem::deselectEvent ( bool * selectionStateChanged)
overrideprotectedvirtual

This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.

just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.

See also
selectTest, selectEvent

Reimplemented from QCPLayerable.

Definition at line 18882 of file qcustomplot.cpp.

◆ draw()

virtual void QCPAbstractLegendItem::draw ( QCPPainter * painter)
overrideprotectedpure virtual

This function draws the layerable with the specified painter. It is only called by QCustomPlot, if the layerable is visible (setVisible).

Before this function is called, the painter's antialiasing state is set via applyDefaultAntialiasingHint, see the documentation there. Further, the clipping rectangle was set to clipRect.

Reimplemented from QCPLayoutElement.

Implemented in QCPPlottableLegendItem, and QCPPolarLegendItem.

◆ font()

QFont QCPAbstractLegendItem::font ( ) const
inline

Definition at line 5067 of file qcustomplot.h.

◆ parentLegend()

QCPLegend * QCPAbstractLegendItem::parentLegend ( ) const
inline

Definition at line 5066 of file qcustomplot.h.

◆ selectable()

bool QCPAbstractLegendItem::selectable ( ) const
inline

Definition at line 5071 of file qcustomplot.h.

◆ selected()

bool QCPAbstractLegendItem::selected ( ) const
inline

Definition at line 5072 of file qcustomplot.h.

◆ selectedFont()

QFont QCPAbstractLegendItem::selectedFont ( ) const
inline

Definition at line 5069 of file qcustomplot.h.

◆ selectedTextColor()

QColor QCPAbstractLegendItem::selectedTextColor ( ) const
inline

Definition at line 5070 of file qcustomplot.h.

◆ selectEvent()

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

This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.

event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).

Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is fed back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.

selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.

See also
selectTest, deselectEvent

Reimplemented from QCPLayerable.

Definition at line 18868 of file qcustomplot.cpp.

◆ selectionCategory()

QCP::Interaction QCPAbstractLegendItem::selectionCategory ( ) const
overrideprotectedvirtual

Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.

Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.

See also
QCustomPlot::setInteractions

Reimplemented from QCPLayerable.

Definition at line 19619 of file qcustomplot.cpp.

◆ selectionChanged

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.

◆ selectTest()

double QCPAbstractLegendItem::selectTest ( const QPointF & pos,
bool onlySelectable,
QVariant * details = nullptr ) const
overridevirtual

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 18842 of file qcustomplot.cpp.

◆ setFont()

void QCPAbstractLegendItem::setFont ( const QFont & font)

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

See also
setTextColor, QCPLegend::setFont

Definition at line 18773 of file qcustomplot.cpp.

◆ setSelectable()

void QCPAbstractLegendItem::setSelectable ( bool selectable)

Sets whether this specific legend item is selectable.

See also
setSelectedParts, QCustomPlot::setInteractions

Definition at line 18815 of file qcustomplot.cpp.

◆ setSelected()

void QCPAbstractLegendItem::setSelected ( bool selected)

Sets whether this specific legend item is selected.

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
setSelectableParts, QCustomPlot::setInteractions

Definition at line 18832 of file qcustomplot.cpp.

◆ setSelectedFont()

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

Definition at line 18794 of file qcustomplot.cpp.

◆ setSelectedTextColor()

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

Definition at line 18805 of file qcustomplot.cpp.

◆ setTextColor()

void QCPAbstractLegendItem::setTextColor ( const QColor & color)

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

See also
setFont, QCPLegend::setTextColor

Definition at line 18783 of file qcustomplot.cpp.

◆ textColor()

QColor QCPAbstractLegendItem::textColor ( ) const
inline

Definition at line 5068 of file qcustomplot.h.

Member Data Documentation

◆ mFont

QFont QCPAbstractLegendItem::mFont
protected

Definition at line 5092 of file qcustomplot.h.

◆ mParentLegend

QCPLegend* QCPAbstractLegendItem::mParentLegend
protected

Definition at line 5091 of file qcustomplot.h.

◆ mSelectable

bool QCPAbstractLegendItem::mSelectable
protected

Definition at line 5096 of file qcustomplot.h.

◆ mSelected

bool QCPAbstractLegendItem::mSelected
protected

Definition at line 5096 of file qcustomplot.h.

◆ mSelectedFont

QFont QCPAbstractLegendItem::mSelectedFont
protected

Definition at line 5094 of file qcustomplot.h.

◆ mSelectedTextColor

QColor QCPAbstractLegendItem::mSelectedTextColor
protected

Definition at line 5095 of file qcustomplot.h.

◆ mTextColor

QColor QCPAbstractLegendItem::mTextColor
protected

Definition at line 5093 of file qcustomplot.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.