QCPLegend
Public Types | |
enum | SelectablePart { spNone = 0x000 , spLegendBox = 0x001 , spItems = 0x002 } |
typedef QFlags< SelectablePart > | SelectableParts |
Public Types inherited from QCPLayoutGrid | |
enum | FillOrder { foRowsFirst , foColumnsFirst } |
Public Types inherited from QCPLayoutElement | |
enum | SizeConstraintRect { scrInnerRect , scrOuterRect } |
enum | UpdatePhase { upPreparation , upMargins , upLayout } |
Public Types inherited from QObject | |
typedef | QObjectList |
Signals | |
void | selectableChanged (QCPLegend::SelectableParts parts) |
void | selectionChanged (QCPLegend::SelectableParts parts) |
Signals inherited from QCPLayerable | |
void | layerChanged (QCPLayer *newLayer) |
Public Member Functions | |
QCPLegend () | |
bool | addItem (QCPAbstractLegendItem *item) |
QPen | borderPen () const |
QBrush | brush () const |
void | clearItems () |
QFont | font () const |
bool | hasItem (QCPAbstractLegendItem *item) const |
bool | hasItemWithPlottable (const QCPAbstractPlottable *plottable) const |
QPen | iconBorderPen () const |
QSize | iconSize () const |
int | iconTextPadding () const |
QCPAbstractLegendItem * | item (int index) const |
int | itemCount () const |
QCPPlottableLegendItem * | itemWithPlottable (const QCPAbstractPlottable *plottable) const |
bool | removeItem (int index) |
bool | removeItem (QCPAbstractLegendItem *item) |
SelectableParts | selectableParts () const |
QPen | selectedBorderPen () const |
QBrush | selectedBrush () const |
QFont | selectedFont () const |
QPen | selectedIconBorderPen () const |
QList< QCPAbstractLegendItem * > | selectedItems () const |
SelectableParts | selectedParts () const |
QColor | selectedTextColor () const |
virtual double | selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const override |
void | setBorderPen (const QPen &pen) |
void | setBrush (const QBrush &brush) |
void | setFont (const QFont &font) |
void | setIconBorderPen (const QPen &pen) |
void | setIconSize (const QSize &size) |
void | setIconSize (int width, int height) |
void | setIconTextPadding (int padding) |
Q_SLOT void | setSelectableParts (const SelectableParts &selectableParts) |
void | setSelectedBorderPen (const QPen &pen) |
void | setSelectedBrush (const QBrush &brush) |
void | setSelectedFont (const QFont &font) |
void | setSelectedIconBorderPen (const QPen &pen) |
Q_SLOT void | setSelectedParts (const SelectableParts &selectedParts) |
void | setSelectedTextColor (const QColor &color) |
void | setTextColor (const QColor &color) |
QColor | textColor () const |
Public Member Functions inherited from QCPLayoutGrid | |
QCPLayoutGrid () | |
bool | addElement (int row, int column, QCPLayoutElement *element) |
bool | addElement (QCPLayoutElement *element) |
int | columnCount () const |
int | columnSpacing () const |
QList< double > | columnStretchFactors () const |
QCPLayoutElement * | element (int row, int column) const |
virtual QCPLayoutElement * | elementAt (int index) const override |
virtual int | elementCount () const override |
virtual QList< QCPLayoutElement * > | elements (bool recursive) const override |
void | expandTo (int newRowCount, int newColumnCount) |
FillOrder | fillOrder () const |
bool | hasElement (int row, int column) |
void | indexToRowCol (int index, int &row, int &column) const |
void | insertColumn (int newIndex) |
void | insertRow (int newIndex) |
virtual QSize | maximumOuterSizeHint () const override |
virtual QSize | minimumOuterSizeHint () const override |
int | rowColToIndex (int row, int column) const |
int | rowCount () const |
int | rowSpacing () const |
QList< double > | rowStretchFactors () const |
void | setColumnSpacing (int pixels) |
void | setColumnStretchFactor (int column, double factor) |
void | setColumnStretchFactors (const QList< double > &factors) |
void | setFillOrder (FillOrder order, bool rearrange=true) |
void | setRowSpacing (int pixels) |
void | setRowStretchFactor (int row, double factor) |
void | setRowStretchFactors (const QList< double > &factors) |
void | setWrap (int count) |
virtual void | simplify () override |
virtual bool | take (QCPLayoutElement *element) override |
virtual QCPLayoutElement * | takeAt (int index) override |
virtual void | updateLayout () override |
int | wrap () const |
Public Member Functions inherited from QCPLayout | |
QCPLayout () | |
void | clear () |
bool | remove (QCPLayoutElement *element) |
bool | removeAt (int index) |
virtual void | update (UpdatePhase phase) override |
Public Member Functions inherited from QCPLayoutElement | |
QCPLayoutElement (QCustomPlot *parentPlot=nullptr) | |
QCP::MarginSides | autoMargins () const |
QCPLayout * | layout () const |
QCPMarginGroup * | marginGroup (QCP::MarginSide side) const |
QHash< QCP::MarginSide, QCPMarginGroup * > | marginGroups () const |
QMargins | margins () const |
QSize | maximumSize () const |
QMargins | minimumMargins () 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 |
Public Member Functions inherited from QCPLayerable | |
QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=nullptr) | |
bool | antialiased () const |
QCPLayer * | layer () const |
QCPLayerable * | parentLayerable () const |
QCustomPlot * | parentPlot () 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< QString > | bindableObjectName () |
bool | blockSignals (bool block) |
const QObjectList & | children () 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< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | 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 QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () 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 | |
T | qobject_cast (const QObject *object) |
T | 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) |
QThread * | thread () const const |
Protected Member Functions | |
virtual void | applyDefaultAntialiasingHint (QCPPainter *painter) const override |
virtual void | deselectEvent (bool *selectionStateChanged) override |
virtual void | draw (QCPPainter *painter) override |
QPen | getBorderPen () const |
QBrush | getBrush () const |
virtual void | parentPlotInitialized (QCustomPlot *parentPlot) override |
virtual void | selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) override |
virtual QCP::Interaction | selectionCategory () const override |
Protected Member Functions inherited from QCPLayoutGrid | |
void | getMaximumRowColSizes (QVector< int > *maxColWidths, QVector< int > *maxRowHeights) const |
void | getMinimumRowColSizes (QVector< int > *minColWidths, QVector< int > *minRowHeights) const |
Protected Member Functions inherited from QCPLayout | |
void | adoptElement (QCPLayoutElement *el) |
QVector< int > | getSectionSizes (QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const |
void | releaseElement (QCPLayoutElement *el) |
void | sizeConstraintsChanged () const |
Protected Member Functions inherited from QCPLayoutElement | |
virtual int | calculateAutoMargin (QCP::MarginSide side) |
virtual void | layoutChanged () |
Protected Member Functions inherited from QCPLayerable | |
void | applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const |
virtual QRect | clipRect () 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 |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Additional Inherited Members | |
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) |
Static Protected Member Functions inherited from QCPLayout | |
static QSize | getFinalMaximumOuterSize (const QCPLayoutElement *el) |
static QSize | getFinalMinimumOuterSize (const QCPLayoutElement *el) |
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.
A legend is populated with legend items by calling QCPAbstractPlottable::addToLegend on the plottable, for which a legend item shall be created. In the case of the main legend (QCustomPlot::legend), simply adding plottables to the plot while QCustomPlot::setAutoAddPlottableToLegend is set to true (the default) creates corresponding legend items. The legend item associated with a certain plottable 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.
Since QCPLegend derives from QCPLayoutGrid, it 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. See the special page about The Layout System for examples on how to add other elements to the legend and move it outside the axis rect.
Use the methods setFillOrder and setWrap inherited from QCPLayoutGrid to control in which order (column first or row first) the legend is filled up when calling addItem, and at which column or row wrapping occurs. The default fill order for legends is foRowsFirst.
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 5138 of file qcustomplot.h.
Member Typedef Documentation
◆ SelectableParts
Definition at line 5169 of file qcustomplot.h.
Member Enumeration Documentation
◆ SelectablePart
Defines the selectable parts of a legend
- See also
- setSelectedParts, setSelectableParts
Enumerator | |
---|---|
spNone |
|
spLegendBox |
|
spItems |
|
Definition at line 5163 of file qcustomplot.h.
Constructor & Destructor Documentation
◆ QCPLegend()
|
explicit |
Constructs a new QCPLegend instance with default values.
Note that by default, QCustomPlot already contains a legend ready to be used as QCustomPlot::legend
Definition at line 19075 of file qcustomplot.cpp.
◆ ~QCPLegend()
|
overridevirtual |
Definition at line 19102 of file qcustomplot.cpp.
Member Function Documentation
◆ addItem()
bool QCPLegend::addItem | ( | QCPAbstractLegendItem * | item | ) |
Adds item to the legend, if it's not present already. The element is arranged according to the current fill order (setFillOrder) and wrapping (setWrap).
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.
- See also
- removeItem, item, hasItem
Definition at line 19434 of file qcustomplot.cpp.
◆ applyDefaultAntialiasingHint()
|
overrideprotectedvirtual |
A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing main legend elements.
This is the antialiasing state the painter passed to the draw method is in by default.
This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.
\seebaseclassmethod
- See also
- setAntialiased
Reimplemented from QCPLayoutElement.
Definition at line 19532 of file qcustomplot.cpp.
◆ borderPen()
|
inline |
Definition at line 5175 of file qcustomplot.h.
◆ brush()
|
inline |
Definition at line 5176 of file qcustomplot.h.
◆ clearItems()
void QCPLegend::clearItems | ( | ) |
Removes all items from the legend.
Definition at line 19487 of file qcustomplot.cpp.
◆ deselectEvent()
|
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 19600 of file qcustomplot.cpp.
◆ draw()
|
overrideprotectedvirtual |
Draws the legend box with the provided painter. The individual legend items are layerables themselves, thus are drawn independently.
Reimplemented from QCPLayoutElement.
Definition at line 19562 of file qcustomplot.cpp.
◆ font()
|
inline |
Definition at line 5177 of file qcustomplot.h.
◆ getBorderPen()
|
protected |
Returns the pen used to paint the border of the legend, taking into account the selection state of the legend box.
Definition at line 19542 of file qcustomplot.cpp.
◆ getBrush()
|
protected |
Returns the brush used to paint the background of the legend, taking into account the selection state of the legend box.
Definition at line 19552 of file qcustomplot.cpp.
◆ hasItem()
bool QCPLegend::hasItem | ( | QCPAbstractLegendItem * | item | ) | const |
Returns whether the legend contains item.
- See also
- hasItemWithPlottable
Definition at line 19403 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 19419 of file qcustomplot.cpp.
◆ iconBorderPen()
|
inline |
Definition at line 5181 of file qcustomplot.h.
◆ iconSize()
|
inline |
Definition at line 5179 of file qcustomplot.h.
◆ iconTextPadding()
|
inline |
Definition at line 5180 of file qcustomplot.h.
◆ item()
QCPAbstractLegendItem * QCPLegend::item | ( | int | index | ) | const |
Returns the item with index i. If non-legend items were added to the legend, and the element at the specified cell index is not a QCPAbstractLegendItem, returns nullptr
.
Note that the linear index depends on the current fill order (setFillOrder).
- See also
- itemCount, addItem, itemWithPlottable
Definition at line 19359 of file qcustomplot.cpp.
◆ itemCount()
int QCPLegend::itemCount | ( | ) | const |
Returns the number of items currently in the legend. It is identical to the base class QCPLayoutGrid::elementCount(), and unlike the other "item" interface methods of QCPLegend, doesn't only address elements which can be cast to QCPAbstractLegendItem.
Note that if empty cells are in the legend (e.g. by calling methods of the QCPLayoutGrid base class which allows creating empty cells), they are included in the returned count.
- See also
- item
Definition at line 19393 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 nullptr
.
- See also
- hasItemWithPlottable
Definition at line 19370 of file qcustomplot.cpp.
◆ parentPlotInitialized()
|
overrideprotectedvirtual |
propagates the parent plot initialization to all child elements, by calling QCPLayerable::initializeParentPlot on them.
Reimplemented from QCPLayoutElement.
Definition at line 19625 of file qcustomplot.cpp.
◆ removeItem() [1/2]
bool QCPLegend::removeItem | ( | int | index | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Removes the item with the specified index from the legend and deletes it.
After successful removal, the legend is reordered according to the current fill order (setFillOrder) and wrapping (setWrap), so no empty cell remains where the removed item was. If you don't want this, rather use the raw element interface of QCPLayoutGrid.
Returns true, if successful. Unlike QCPLayoutGrid::removeAt, this method only removes elements derived from QCPAbstractLegendItem.
- See also
- itemCount, clearItems
Definition at line 19452 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 and deletes it.
After successful removal, the legend is reordered according to the current fill order (setFillOrder) and wrapping (setWrap), so no empty cell remains where the removed item was. If you don't want this, rather use the raw element interface of QCPLayoutGrid.
Returns true, if successful.
- See also
- clearItems
Definition at line 19476 of file qcustomplot.cpp.
◆ selectableParts()
|
inline |
Definition at line 5182 of file qcustomplot.h.
◆ selectedBorderPen()
|
inline |
Definition at line 5184 of file qcustomplot.h.
◆ selectedBrush()
|
inline |
Definition at line 5186 of file qcustomplot.h.
◆ selectedFont()
|
inline |
Definition at line 5187 of file qcustomplot.h.
◆ selectedIconBorderPen()
|
inline |
Definition at line 5185 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 19503 of file qcustomplot.cpp.
◆ selectedParts()
QCPLegend::SelectableParts QCPLegend::selectedParts | ( | ) | const |
Definition at line 19110 of file qcustomplot.cpp.
◆ selectedTextColor()
|
inline |
Definition at line 5188 of file qcustomplot.h.
◆ selectEvent()
|
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 19586 of file qcustomplot.cpp.
◆ selectionCategory()
|
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 19613 of file qcustomplot.cpp.
◆ selectionChanged
|
signal |
This signal is emitted when the selection state of this legend has changed.
- See also
- setSelectedParts, setSelectableParts
◆ selectTest()
|
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 19571 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 19131 of file qcustomplot.cpp.
◆ setBrush()
void QCPLegend::setBrush | ( | const QBrush & | brush | ) |
Sets the brush of the legend background.
Definition at line 19139 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 19153 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 19215 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 19186 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 19193 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 19204 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 19230 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.
Definition at line 19291 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.
Definition at line 19312 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.
Definition at line 19324 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.
Definition at line 19301 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 19260 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.
Definition at line 19341 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.
Definition at line 19172 of file qcustomplot.cpp.
◆ textColor()
|
inline |
Definition at line 5178 of file qcustomplot.h.
Member Data Documentation
◆ mBorderPen
|
protected |
Definition at line 5228 of file qcustomplot.h.
◆ mBrush
|
protected |
Definition at line 5229 of file qcustomplot.h.
◆ mFont
|
protected |
Definition at line 5230 of file qcustomplot.h.
◆ mIconBorderPen
|
protected |
Definition at line 5228 of file qcustomplot.h.
◆ mIconSize
|
protected |
Definition at line 5232 of file qcustomplot.h.
◆ mIconTextPadding
|
protected |
Definition at line 5233 of file qcustomplot.h.
◆ mSelectableParts
|
protected |
Definition at line 5234 of file qcustomplot.h.
◆ mSelectedBorderPen
|
protected |
Definition at line 5235 of file qcustomplot.h.
◆ mSelectedBrush
|
protected |
Definition at line 5236 of file qcustomplot.h.
◆ mSelectedFont
|
protected |
Definition at line 5237 of file qcustomplot.h.
◆ mSelectedIconBorderPen
|
protected |
Definition at line 5235 of file qcustomplot.h.
◆ mSelectedParts
|
protected |
Definition at line 5234 of file qcustomplot.h.
◆ mSelectedTextColor
|
protected |
Definition at line 5238 of file qcustomplot.h.
◆ mTextColor
|
protected |
Definition at line 5231 of file qcustomplot.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.