QCPTextElement

Search for usage in LXR

Inheritance diagram for QCPTextElement:

Signals

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

Public Member Functions

 QCPTextElement (QCustomPlot *parentPlot)
 
 QCPTextElement (QCustomPlot *parentPlot, const QString &text)
 
 QCPTextElement (QCustomPlot *parentPlot, const QString &text, const QFont &font)
 
 QCPTextElement (QCustomPlot *parentPlot, const QString &text, const QString &fontFamily, double pointSize)
 
 QCPTextElement (QCustomPlot *parentPlot, const QString &text, double pointSize)
 
QFont font () const
 
virtual void mouseDoubleClickEvent (QMouseEvent *event, const QVariant &details) override
 
virtual void mousePressEvent (QMouseEvent *event, const QVariant &details) override
 
virtual void mouseReleaseEvent (QMouseEvent *event, const QPointF &startPos) override
 
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 setText (const QString &text)
 
void setTextColor (const QColor &color)
 
void setTextFlags (int flags)
 
QString text () const
 
QColor textColor () const
 
int textFlags () 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
 
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
 
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)
 
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 ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
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 QRegExp &regExp, 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
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
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_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 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
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
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 setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Protected Member Functions

virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const override
 
virtual void deselectEvent (bool *selectionStateChanged) override
 
virtual void draw (QCPPainter *painter) override
 
QFont mainFont () const
 
QColor mainTextColor () const
 
virtual QSize maximumOuterSizeHint () const override
 
virtual QSize minimumOuterSizeHint () const override
 
virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) 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
 
virtual QRect clipRect () const
 
void initializeParentPlot (QCustomPlot *parentPlot)
 
virtual void mouseMoveEvent (QMouseEvent *event, const QPointF &startPos)
 
bool moveToLayer (QCPLayer *layer, bool prepend)
 
virtual QCP::Interaction selectionCategory () const
 
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
 
bool mSelectable
 
bool mSelected
 
QFont mSelectedFont
 
QColor mSelectedTextColor
 
QString mText
 
QRect mTextBoundingRect
 
QColor mTextColor
 
int mTextFlags
 
- 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 }
 
- 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)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QObject
typedef QObjectList
 

Detailed Description

A layout element displaying a text.

The text may be specified with setText, the formatting can be controlled with setFont, setTextColor, and setTextFlags.

A text element can be added as follows:

Definition at line 5214 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPTextElement() [1/5]

QCPTextElement::QCPTextElement ( QCustomPlot parentPlot)
explicit

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

Creates a new QCPTextElement instance and sets default values. The initial text is empty (setText).

Definition at line 19675 of file qcustomplot.cpp.

◆ QCPTextElement() [2/5]

QCPTextElement::QCPTextElement ( QCustomPlot parentPlot,
const QString text 
)

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

Creates a new QCPTextElement instance and sets default values.

The initial text is set to text.

Definition at line 19700 of file qcustomplot.cpp.

◆ QCPTextElement() [3/5]

QCPTextElement::QCPTextElement ( QCustomPlot parentPlot,
const QString text,
double  pointSize 
)

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

Creates a new QCPTextElement instance and sets default values.

The initial text is set to text with pointSize.

Definition at line 19725 of file qcustomplot.cpp.

◆ QCPTextElement() [4/5]

QCPTextElement::QCPTextElement ( QCustomPlot parentPlot,
const QString text,
const QString fontFamily,
double  pointSize 
)

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

Creates a new QCPTextElement instance and sets default values.

The initial text is set to text with pointSize and the specified fontFamily.

Definition at line 19753 of file qcustomplot.cpp.

◆ QCPTextElement() [5/5]

QCPTextElement::QCPTextElement ( QCustomPlot parentPlot,
const QString text,
const QFont font 
)

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

Creates a new QCPTextElement instance and sets default values.

The initial text is set to text with the specified font.

Definition at line 19774 of file qcustomplot.cpp.

Member Function Documentation

◆ applyDefaultAntialiasingHint()

void QCPTextElement::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 19895 of file qcustomplot.cpp.

◆ clicked

void QCPTextElement::clicked ( QMouseEvent event)
signal

This signal is emitted when the text element is clicked.

See also
doubleClicked, selectTest

◆ deselectEvent()

void QCPTextElement::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 19943 of file qcustomplot.cpp.

◆ doubleClicked

void QCPTextElement::doubleClicked ( QMouseEvent event)
signal

This signal is emitted when the text element is double clicked.

See also
clicked, selectTest

◆ draw()

void QCPTextElement::draw ( QCPPainter painter)
overrideprotectedvirtual

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.

Definition at line 19901 of file qcustomplot.cpp.

◆ mainFont()

QFont QCPTextElement::mainFont ( ) const
protected

Returns the main font to be used. This is mSelectedFont if setSelected is set to true, else mFont is returned.

Definition at line 20016 of file qcustomplot.cpp.

◆ mainTextColor()

QColor QCPTextElement::mainTextColor ( ) const
protected

Returns the main color to be used. This is mSelectedTextColor if setSelected is set to true, else mTextColor is returned.

Definition at line 20026 of file qcustomplot.cpp.

◆ maximumOuterSizeHint()

QSize QCPTextElement::maximumOuterSizeHint ( ) const
overrideprotectedvirtual

Returns the suggested maximum size this layout element (the outerRect) may be expanded to, if no manual maximum size is set.

if a maximum size (setMaximumSize) was not set manually, parent layouts use the returned size (usually indirectly through QCPLayout::getFinalMaximumOuterSize) to determine the maximum allowed size of this layout element.

A manual maximum size is considered set if it is smaller than Qt's QWIDGETSIZE_MAX.

The default implementation simply returns QWIDGETSIZE_MAX for both width and height, implying no suggested maximum size. Reimplementations may use their detailed knowledge about the layout element's content to provide size hints.

Reimplemented from QCPLayoutElement.

Definition at line 19919 of file qcustomplot.cpp.

◆ minimumOuterSizeHint()

QSize QCPTextElement::minimumOuterSizeHint ( ) const
overrideprotectedvirtual

Returns the suggested minimum size this layout element (the outerRect) may be compressed to, if no manual minimum size is set.

if a minimum size (setMinimumSize) was not set manually, parent layouts use the returned size (usually indirectly through QCPLayout::getFinalMinimumOuterSize) to determine the minimum allowed size of this layout element.

A manual minimum size is considered set if it is non-zero.

The default implementation simply returns the sum of the horizontal margins for the width and the sum of the vertical margins for the height. Reimplementations may use their detailed knowledge about the layout element's content to provide size hints.

Reimplemented from QCPLayoutElement.

Definition at line 19909 of file qcustomplot.cpp.

◆ mouseDoubleClickEvent()

void QCPTextElement::mouseDoubleClickEvent ( QMouseEvent event,
const QVariant details 
)
overridevirtual

Emits the doubleClicked signal.

\seebaseclassmethod

Reimplemented from QCPLayerable.

Definition at line 20005 of file qcustomplot.cpp.

◆ mousePressEvent()

void QCPTextElement::mousePressEvent ( QMouseEvent event,
const QVariant details 
)
overridevirtual

Accepts the mouse event in order to emit the according click signal in the mouseReleaseEvent.

\seebaseclassmethod

Reimplemented from QCPLayerable.

Definition at line 19982 of file qcustomplot.cpp.

◆ mouseReleaseEvent()

void QCPTextElement::mouseReleaseEvent ( QMouseEvent event,
const QPointF startPos 
)
overridevirtual

Emits the clicked signal if the cursor hasn't moved by more than a few pixels since the mousePressEvent.

\seebaseclassmethod

Reimplemented from QCPLayerable.

Definition at line 19994 of file qcustomplot.cpp.

◆ selectEvent()

void QCPTextElement::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 19929 of file qcustomplot.cpp.

◆ selectionChanged

void QCPTextElement::selectionChanged ( bool  selected)
signal

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

See also
setSelected, setSelectable

◆ selectTest()

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

Returns 0.99*selectionTolerance (see QCustomPlot::setSelectionTolerance) when pos is within the bounding box of the text element's text. Note that this bounding box is updated in the draw call.

If pos is outside the text's bounding box or if onlySelectable is true and this text element is not selectable (setSelectable), returns -1.

\seebaseclassmethod

Reimplemented from QCPLayoutElement.

Definition at line 19964 of file qcustomplot.cpp.

◆ setFont()

void QCPTextElement::setFont ( const QFont font)

Sets the font of the text.

See also
setTextColor, setSelectedFont

Definition at line 19828 of file qcustomplot.cpp.

◆ setSelectable()

void QCPTextElement::setSelectable ( bool  selectable)

Sets whether the user may select this text element.

Note that even when selectable is set to false, the selection state may be changed programmatically via setSelected.

Definition at line 19869 of file qcustomplot.cpp.

◆ setSelected()

void QCPTextElement::setSelected ( bool  selected)

Sets the selection state of this text element to selected. If the selection has changed, selectionChanged is emitted.

Note that this function can change the selection state independently of the current setSelectable state.

Definition at line 19885 of file qcustomplot.cpp.

◆ setSelectedFont()

void QCPTextElement::setSelectedFont ( const QFont font)

Sets the font of the text that will be used if the text element is selected (setSelected).

See also
setFont

Definition at line 19848 of file qcustomplot.cpp.

◆ setSelectedTextColor()

void QCPTextElement::setSelectedTextColor ( const QColor color)

Sets the color of the text that will be used if the text element is selected (setSelected).

See also
setTextColor

Definition at line 19858 of file qcustomplot.cpp.

◆ setText()

void QCPTextElement::setText ( const QString text)

Sets the text that will be displayed to text. Multiple lines can be created by insertion of "\n".

See also
setFont, setTextColor, setTextFlags

Definition at line 19793 of file qcustomplot.cpp.

◆ setTextColor()

void QCPTextElement::setTextColor ( const QColor color)

Sets the color of the text.

See also
setFont, setSelectedTextColor

Definition at line 19838 of file qcustomplot.cpp.

◆ setTextFlags()

void QCPTextElement::setTextFlags ( int  flags)

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:01:01 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.