OmronPID
Loading...
Searching...
No Matches
Signals | Public Member Functions | Protected Member Functions | Protected Attributes
QCPTextElement Class Reference

A layout element displaying a text. More...

Inheritance diagram for QCPTextElement:
QCPLayoutElement QCPLayerable

Signals

void selectionChanged (bool selected)
 This signal is emitted when the selection state has changed to selected, either by user interaction or by a direct call to setSelected.
 
void selectableChanged (bool selectable)
 
void clicked (QMouseEvent *event)
 This signal is emitted when the text element is clicked.
 
void doubleClicked (QMouseEvent *event)
 This signal is emitted when the text element is double clicked.
 
- Signals inherited from QCPLayerable
void layerChanged (QCPLayer *newLayer)
 This signal is emitted when the layer of this layerable changes, i.e.
 

Public Member Functions

 QCPTextElement (QCustomPlot *parentPlot)
 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.
 
 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.
 
 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.
 
 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.
 
 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.
 
QString text () const
 
int textFlags () const
 
QFont font () const
 
QColor textColor () const
 
QFont selectedFont () const
 
QColor selectedTextColor () const
 
bool selectable () const
 
bool selected () const
 
void setText (const QString &text)
 Sets the text that will be displayed to text.
 
void setTextFlags (int flags)
 Sets options for text alignment and wrapping behaviour.
 
void setFont (const QFont &font)
 Sets the font of the text.
 
void setTextColor (const QColor &color)
 Sets the color of the text.
 
void setSelectedFont (const QFont &font)
 Sets the font of the text that will be used if the text element is selected (setSelected).
 
void setSelectedTextColor (const QColor &color)
 Sets the color of the text that will be used if the text element is selected (setSelected).
 
Q_SLOT void setSelectable (bool selectable)
 Sets whether the user may select this text element.
 
Q_SLOT void setSelected (bool selected)
 Sets the selection state of this text element to selected.
 
virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
 Returns 0.99*selectionTolerance (see QCustomPlot::setSelectionTolerance) when pos is within the bounding box of the text element's text.
 
virtual void mousePressEvent (QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
 Accepts the mouse event in order to emit the according click signal in the mouseReleaseEvent.
 
virtual void mouseReleaseEvent (QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
 Emits the clicked signal if the cursor hasn't moved by more than a few pixels since the mousePressEvent.
 
virtual void mouseDoubleClickEvent (QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
 Emits the doubleClicked signal.
 
- Public Member Functions inherited from QCPLayoutElement
 QCPLayoutElement (QCustomPlot *parentPlot=0)
 Creates an instance of QCPLayoutElement and sets default values.
 
QCPLayoutlayout () const
 Returns the parent layout of this layout element.
 
QRect rect () const
 Returns the inner rect of this layout element.
 
QRect outerRect () const
 Returns the outer rect of this layout element.
 
QMargins margins () const
 
QMargins minimumMargins () const
 
QCP::MarginSides autoMargins () const
 
QSize minimumSize () const
 
QSize maximumSize () const
 
SizeConstraintRect sizeConstraintRect () const
 
QCPMarginGroupmarginGroup (QCP::MarginSide side) const
 
QHash< QCP::MarginSide, QCPMarginGroup * > marginGroups () const
 
void setOuterRect (const QRect &rect)
 Sets the outer rect of this layout element.
 
void setMargins (const QMargins &margins)
 Sets the margins of this layout element.
 
void setMinimumMargins (const QMargins &margins)
 If setAutoMargins is enabled on some or all margins, this function is used to provide minimum values for those margins.
 
void setAutoMargins (QCP::MarginSides sides)
 Sets on which sides the margin shall be calculated automatically.
 
void setMinimumSize (const QSize &size)
 Sets the minimum size of this layout element.
 
void setMinimumSize (int width, int height)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the minimum size of this layout element.
 
void setMaximumSize (const QSize &size)
 Sets the maximum size of this layout element.
 
void setMaximumSize (int width, int height)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the maximum size of this layout element.
 
void setSizeConstraintRect (SizeConstraintRect constraintRect)
 Sets to which rect of a layout element the size constraints apply.
 
void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group)
 Sets the margin group of the specified margin sides.
 
virtual void update (UpdatePhase phase)
 Updates the layout element and sub-elements.
 
virtual QSize minimumOuterSizeHint () const
 Returns the suggested minimum size this layout element (the outerRect) may be compressed to, if no manual minimum size is set.
 
virtual QSize maximumOuterSizeHint () const
 Returns the suggested maximum size this layout element (the outerRect) may be expanded to, if no manual maximum size is set.
 
virtual QList< QCPLayoutElement * > elements (bool recursive) const
 Returns a list of all child elements in this layout element.
 
virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
 Layout elements are sensitive to events inside their outer rect.
 
- Public Member Functions inherited from QCPLayerable
 QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=0)
 Creates a new QCPLayerable instance.
 
bool visible () const
 
QCustomPlotparentPlot () const
 
QCPLayerableparentLayerable () const
 Returns the parent layerable of this layerable.
 
QCPLayerlayer () const
 
bool antialiased () const
 
void setVisible (bool on)
 Sets the visibility of this layerable object.
 
Q_SLOT bool setLayer (QCPLayer *layer)
 Sets the layer of this layerable object.
 
bool setLayer (const QString &layerName)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the layer of this layerable object by name.
 
void setAntialiased (bool enabled)
 Sets whether this object will be drawn antialiased or not.
 
virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const
 This function is used to decide whether a click hits a layerable object or not.
 
bool realVisibility () const
 Returns whether this layerable is visible, taking the visibility of the layerable parent and the visibility of this layerable's layer into account.
 

Protected Member Functions

virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const Q_DECL_OVERRIDE
 
virtual void draw (QCPPainter *painter) Q_DECL_OVERRIDE
 
virtual QSize minimumOuterSizeHint () const Q_DECL_OVERRIDE
 Returns the suggested minimum size this layout element (the outerRect) may be compressed to, if no manual minimum size is set.
 
virtual QSize maximumOuterSizeHint () const Q_DECL_OVERRIDE
 Returns the suggested maximum size this layout element (the outerRect) may be expanded to, if no manual maximum size is set.
 
virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
 
virtual void deselectEvent (bool *selectionStateChanged) Q_DECL_OVERRIDE
 
QFont mainFont () const
 
QColor mainTextColor () const
 
- Protected Member Functions inherited from QCPLayoutElement
virtual int calculateAutoMargin (QCP::MarginSide side)
 
virtual void layoutChanged ()
 
virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const Q_DECL_OVERRIDE
 
virtual void draw (QCPPainter *painter) Q_DECL_OVERRIDE
 
virtual void parentPlotInitialized (QCustomPlot *parentPlot) Q_DECL_OVERRIDE
 
- Protected Member Functions inherited from QCPLayerable
virtual void parentPlotInitialized (QCustomPlot *parentPlot)
 
virtual QCP::Interaction selectionCategory () const
 
virtual QRect clipRect () const
 
virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const =0
 
virtual void draw (QCPPainter *painter)=0
 
virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
 
virtual void deselectEvent (bool *selectionStateChanged)
 
virtual void mousePressEvent (QMouseEvent *event, const QVariant &details)
 This event gets called when the user presses a mouse button while the cursor is over the layerable.
 
virtual void mouseMoveEvent (QMouseEvent *event, const QPointF &startPos)
 This event gets called when the user moves the mouse while holding a mouse button, after this layerable has become the mouse grabber by accepting the preceding mousePressEvent.
 
virtual void mouseReleaseEvent (QMouseEvent *event, const QPointF &startPos)
 This event gets called when the user releases the mouse button, after this layerable has become the mouse grabber by accepting the preceding mousePressEvent.
 
virtual void mouseDoubleClickEvent (QMouseEvent *event, const QVariant &details)
 This event gets called when the user presses the mouse button a second time in a double-click, while the cursor is over the layerable.
 
virtual void wheelEvent (QWheelEvent *event)
 This event gets called when the user turns the mouse scroll wheel while the cursor is over the layerable.
 
void initializeParentPlot (QCustomPlot *parentPlot)
 
void setParentLayerable (QCPLayerable *parentLayerable)
 
bool moveToLayer (QCPLayer *layer, bool prepend)
 
void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
 

Protected Attributes

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

Additional Inherited Members

- Public Types inherited from QCPLayoutElement
enum  UpdatePhase { upPreparation , upMargins , upLayout }
 Defines the phases of the update process, that happens just before a replot. More...
 
enum  SizeConstraintRect { scrInnerRect , scrOuterRect }
 Defines to which rect of a layout element the size constraints that can be set via setMinimumSize and setMaximumSize apply. More...
 

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:

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).

◆ 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.

◆ 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.

◆ 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.

◆ 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.

Member Function Documentation

◆ applyDefaultAntialiasingHint()

void QCPTextElement::applyDefaultAntialiasingHint ( QCPPainter painter) const
protectedvirtual

Reimplemented from QCPLayoutElement.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ mouseDoubleClickEvent()

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

Emits the doubleClicked signal.

\seebaseclassmethod

Reimplemented from QCPLayerable.

◆ 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.

\seebaseclassmethod

Reimplemented from QCPLayerable.

◆ 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.

\seebaseclassmethod

Reimplemented from QCPLayerable.

◆ selectEvent()

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

Reimplemented from QCPLayerable.

◆ 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.

\seebaseclassmethod

Reimplemented from QCPLayoutElement.

◆ setFont()

void QCPTextElement::setFont ( const QFont &  font)

Sets the font of the text.

See also
setTextColor, setSelectedFont

◆ 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.

◆ 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.

◆ 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

◆ 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

◆ 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

◆ setTextColor()

void QCPTextElement::setTextColor ( const QColor &  color)

Sets the color of the text.

See also
setFont, setSelectedTextColor

◆ 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

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