Signals | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QCPTextElement Class Reference

A layout element displaying a text. More...

#include <qcustomplot.h>

Inheritance diagram for QCPTextElement:
Inheritance graph
[legend]

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

QFont font () const
 
virtual void mouseDoubleClickEvent (QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
 
virtual void mousePressEvent (QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
 
virtual void mouseReleaseEvent (QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
 
 QCPTextElement (QCustomPlot *parentPlot)
 
 QCPTextElement (QCustomPlot *parentPlot, const QString &text)
 
 QCPTextElement (QCustomPlot *parentPlot, const QString &text, double pointSize)
 
 QCPTextElement (QCustomPlot *parentPlot, const QString &text, const QString &fontFamily, double pointSize)
 
 QCPTextElement (QCustomPlot *parentPlot, const QString &text, const QFont &font)
 
bool selectable () const
 
bool selected () const
 
QFont selectedFont () const
 
QColor selectedTextColor () const
 
virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_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
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
 
 QCPLayoutElement (QCustomPlot *parentPlot=0)
 
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)
 
virtual ~QCPLayoutElement ()
 
- Public Member Functions inherited from QCPLayerable
bool antialiased () const
 
QCPLayerlayer () const
 
QCPLayerableparentLayerable () const
 
QCustomPlotparentPlot () const
 
 QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=0)
 
bool realVisibility () const
 
void setAntialiased (bool enabled)
 
Q_SLOT bool setLayer (QCPLayer *layer)
 
bool setLayer (const QString &layerName)
 
void setVisible (bool on)
 
bool visible () const
 
virtual ~QCPLayerable ()
 

Protected Member Functions

virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const Q_DECL_OVERRIDE
 
virtual void deselectEvent (bool *selectionStateChanged) Q_DECL_OVERRIDE
 
virtual void draw (QCPPainter *painter) Q_DECL_OVERRIDE
 
QFont mainFont () const
 
QColor mainTextColor () const
 
virtual QSize maximumOuterSizeHint () const Q_DECL_OVERRIDE
 
virtual QSize minimumOuterSizeHint () const Q_DECL_OVERRIDE
 
virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
 
- Protected Member Functions inherited from QCPLayoutElement
virtual int calculateAutoMargin (QCP::MarginSide side)
 
virtual void layoutChanged ()
 
virtual void parentPlotInitialized (QCustomPlot *parentPlot) Q_DECL_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 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 }
 

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 4937 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 18925 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 18950 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 18975 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 19002 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 19022 of file qcustomplot.cpp.

Member Function Documentation

◆ applyDefaultAntialiasingHint()

void QCPTextElement::applyDefaultAntialiasingHint ( QCPPainter painter) const
protectedvirtual

Reimplemented from QCPLayoutElement.

Definition at line 19143 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)
protectedvirtual

Reimplemented from QCPLayerable.

Definition at line 19191 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)
protectedvirtual

Reimplemented from QCPLayoutElement.

Definition at line 19149 of file qcustomplot.cpp.

◆ font()

QFont QCPTextElement::font ( ) const
inline

Definition at line 4959 of file qcustomplot.h.

◆ mainFont()

QFont QCPTextElement::mainFont ( ) const
protected

Definition at line 19264 of file qcustomplot.cpp.

◆ mainTextColor()

QColor QCPTextElement::mainTextColor ( ) const
protected

Definition at line 19274 of file qcustomplot.cpp.

◆ maximumOuterSizeHint()

QSize QCPTextElement::maximumOuterSizeHint ( ) const
protectedvirtual

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

◆ minimumOuterSizeHint()

QSize QCPTextElement::minimumOuterSizeHint ( ) const
protectedvirtual

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

◆ mouseDoubleClickEvent()

void QCPTextElement::mouseDoubleClickEvent ( QMouseEvent *  event,
const QVariant &  details 
)
virtual

Emits the doubleClicked signal.

Reimplemented from QCPLayerable.

Definition at line 19253 of file qcustomplot.cpp.

◆ mousePressEvent()

void QCPTextElement::mousePressEvent ( QMouseEvent *  event,
const QVariant &  details 
)
virtual

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

Reimplemented from QCPLayerable.

Definition at line 19230 of file qcustomplot.cpp.

◆ mouseReleaseEvent()

void QCPTextElement::mouseReleaseEvent ( QMouseEvent *  event,
const QPointF &  startPos 
)
virtual

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

Reimplemented from QCPLayerable.

Definition at line 19242 of file qcustomplot.cpp.

◆ selectable()

bool QCPTextElement::selectable ( ) const
inline

Definition at line 4963 of file qcustomplot.h.

◆ selectableChanged

void QCPTextElement::selectableChanged ( bool  selectable)
signal

◆ selected()

bool QCPTextElement::selected ( ) const
inline

Definition at line 4964 of file qcustomplot.h.

◆ selectedFont()

QFont QCPTextElement::selectedFont ( ) const
inline

Definition at line 4961 of file qcustomplot.h.

◆ selectedTextColor()

QColor QCPTextElement::selectedTextColor ( ) const
inline

Definition at line 4962 of file qcustomplot.h.

◆ selectEvent()

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

Reimplemented from QCPLayerable.

Definition at line 19177 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 = 0 
) const
virtual

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.

Reimplemented from QCPLayoutElement.

Definition at line 19212 of file qcustomplot.cpp.

◆ setFont()

void QCPTextElement::setFont ( const QFont &  font)

Sets the font of the text.

See also
setTextColor, setSelectedFont

Definition at line 19076 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 19117 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 19133 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 19096 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 19106 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 19041 of file qcustomplot.cpp.

◆ setTextColor()

void QCPTextElement::setTextColor ( const QColor &  color)

Sets the color of the text.

See also
setFont, setSelectedTextColor

Definition at line 19086 of file qcustomplot.cpp.

◆ setTextFlags()

void QCPTextElement::setTextFlags ( int  flags)

Sets options for text alignment and wrapping behaviour. flags is a bitwise OR-combination of Qt::AlignmentFlag and Qt::TextFlag enums.

Possible enums are:

  • Qt::AlignLeft
  • Qt::AlignRight
  • Qt::AlignHCenter
  • Qt::AlignJustify
  • Qt::AlignTop
  • Qt::AlignBottom
  • Qt::AlignVCenter
  • Qt::AlignCenter
  • Qt::TextDontClip
  • Qt::TextSingleLine
  • Qt::TextExpandTabs
  • Qt::TextShowMnemonic
  • Qt::TextWordWrap
  • Qt::TextIncludeTrailingSpaces

Definition at line 19066 of file qcustomplot.cpp.

◆ text()

QString QCPTextElement::text ( ) const
inline

Definition at line 4957 of file qcustomplot.h.

◆ textColor()

QColor QCPTextElement::textColor ( ) const
inline

Definition at line 4960 of file qcustomplot.h.

◆ textFlags()

int QCPTextElement::textFlags ( ) const
inline

Definition at line 4958 of file qcustomplot.h.

Member Data Documentation

◆ mFont

QFont QCPTextElement::mFont
protected

Definition at line 4992 of file qcustomplot.h.

◆ mSelectable

bool QCPTextElement::mSelectable
protected

Definition at line 4997 of file qcustomplot.h.

◆ mSelected

bool QCPTextElement::mSelected
protected

Definition at line 4997 of file qcustomplot.h.

◆ mSelectedFont

QFont QCPTextElement::mSelectedFont
protected

Definition at line 4994 of file qcustomplot.h.

◆ mSelectedTextColor

QColor QCPTextElement::mSelectedTextColor
protected

Definition at line 4995 of file qcustomplot.h.

◆ mText

QString QCPTextElement::mText
protected

Definition at line 4990 of file qcustomplot.h.

◆ mTextBoundingRect

QRect QCPTextElement::mTextBoundingRect
protected

Definition at line 4996 of file qcustomplot.h.

◆ mTextColor

QColor QCPTextElement::mTextColor
protected

Definition at line 4993 of file qcustomplot.h.

◆ mTextFlags

int QCPTextElement::mTextFlags
protected

Definition at line 4991 of file qcustomplot.h.


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


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Mon Feb 28 2022 22:08:02