QWT API (English) 7.0.1
Qt Widget Library for Technical Applications - English API Documentation
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
QwtText Class Reference

A class representing a text. More...

#include <qwt_text.h>

Classes

class  LayoutCache
 
class  PrivateData
 

Public Types

enum  TextFormat {
  AutoText = 0 , PlainText , RichText , MathMLText ,
  TeXText , OtherFormat = 100
}
 Text format. More...
 
enum  PaintAttribute { PaintUsingTextFont = 0x01 , PaintUsingTextColor = 0x02 , PaintBackground = 0x04 }
 Paint Attributes. More...
 
enum  LayoutAttribute { MinimumLayout = 0x01 }
 Layout Attributes The layout attributes affects some aspects of the layout of the text. . More...
 

Public Member Functions

 QwtText ()
 Default constructor .
 
 QwtText (const QString &, TextFormat textFormat=AutoText)
 Constructor.
 
 QwtText (const QwtText &)
 Copy constructor.
 
 ~QwtText ()
 Destructor .
 
QwtTextoperator= (const QwtText &)
 Assignment operator.
 
bool operator== (const QwtText &) const
 Equality operator.
 
bool operator!= (const QwtText &) const
 Inequality operator.
 
void setText (const QString &, QwtText::TextFormat textFormat=AutoText)
 Assign a new text content.
 
QString text () const
 Get text as QString.
 
bool isNull () const
 Check if text is null.
 
bool isEmpty () const
 Check if text is empty.
 
void setFont (const QFont &)
 Set the font.
 
QFont font () const
 Get the font.
 
QFont usedFont (const QFont &) const
 Return the font of the text, if it has one, otherwise return defaultFont.
 
TextFormat format () const
 Return the format of the text.
 
void setRenderFlags (int)
 Change the render flags.
 
int renderFlags () const
 Get render flags.
 
void setColor (const QColor &)
 Set the pen color used for drawing the text.
 
QColor color () const
 Get the pen color used for painting the text.
 
QColor usedColor (const QColor &) const
 Return the color of the text, if it has one, otherwise return defaultColor.
 
void setBorderRadius (double)
 Set the radius for the corners of the border frame.
 
double borderRadius () const
 Get the radius for the corners of the border frame.
 
void setBorderPen (const QPen &)
 Set the background pen (border pen)
 
QPen borderPen () const
 Get the background pen (border pen)
 
void setBackgroundBrush (const QBrush &)
 Set the background brush.
 
QBrush backgroundBrush () const
 Get the background brush.
 
void setPaintAttribute (PaintAttribute, bool on=true)
 Change a paint attribute.
 
bool testPaintAttribute (PaintAttribute) const
 Test a paint attribute.
 
void setLayoutAttribute (LayoutAttribute, bool on=true)
 Change a layout attribute.
 
bool testLayoutAttribute (LayoutAttribute) const
 Test a layout attribute.
 
double heightForWidth (double width) const
 Find the height for a given width.
 
double heightForWidth (double width, const QFont &) const
 Find the height for a given width.
 
QSizeF textSize () const
 Returns the size that is needed to render text.
 
QSizeF textSize (const QFont &) const
 Returns the size that is needed to render text.
 
void draw (QPainter *painter, const QRectF &rect) const
 Draw a text into a rectangle.
 

Static Public Member Functions

static const QwtTextEnginetextEngine (const QString &text, QwtText::TextFormat=AutoText)
 Find the text engine for a text format.
 
static const QwtTextEnginetextEngine (QwtText::TextFormat)
 Find the text engine for a text format.
 
static void setTextEngine (QwtText::TextFormat, QwtTextEngine *)
 Assign/Replace a text engine for a text format.
 

Detailed Description

A class representing a text.

Member Enumeration Documentation

◆ LayoutAttribute

Layout Attributes The layout attributes affects some aspects of the layout of the text. .

Enumerator
MinimumLayout 

Layout the text without its margins. This mode is useful if a text needs to be aligned accurately, like the tick labels of a scale. If QwtTextEngine::textMargins is not implemented for the format of the text, MinimumLayout has no effect.

◆ PaintAttribute

Paint Attributes.

Enumerator
PaintUsingTextFont 

The text has an individual font.

PaintUsingTextColor 

The text has an individual color.

PaintBackground 

The text has an individual background.

◆ TextFormat

Text format.

Enumerator
AutoText 

The text format is determined using QwtTextEngine::mightRender() for all available text engines in increasing order > PlainText. If none of the text engines can render the text is rendered like QwtText::PlainText.

PlainText 

Draw the text as it is, using a QwtPlainTextEngine.

RichText 

Use the Scribe framework (Qt Rich Text) to render the text.

MathMLText 

Use a MathML (http://en.wikipedia.org/wiki/MathML) render engine to display the text. In earlier versions of Qwt such an engine was included - since Qwt 6.2 it can be found here: https://github.com/uwerat/qwt-mml-dev

To enable MathML support the following code needs to be added to the application:

QwtText::setTextEngine( QwtText::MathMLText, new QwtMathMLTextEngine() );
@ MathMLText
Definition qwt_text.h:161
static void setTextEngine(QwtText::TextFormat, QwtTextEngine *)
Assign/Replace a text engine for a text format.
Definition qwt_text.cpp:1002
TeXText 

Use a TeX (http://en.wikipedia.org/wiki/TeX) render engine to display the text ( not implemented yet ).

OtherFormat 

The number of text formats can be extended using setTextEngine. Formats >= QwtText::OtherFormat are not used by Qwt.

Constructor & Destructor Documentation

◆ QwtText() [1/3]

QwtText::QwtText ( )

Default constructor .

◆ QwtText() [2/3]

QwtText::QwtText ( const QString &  text,
QwtText::TextFormat  textFormat = AutoText 
)

Constructor.

◆ QwtText() [3/3]

QwtText::QwtText ( const QwtText other)

Copy constructor.

◆ ~QwtText()

QwtText::~QwtText ( )

Destructor .

Member Function Documentation

◆ backgroundBrush()

QBrush QwtText::backgroundBrush ( ) const

Get the background brush.

◆ borderPen()

QPen QwtText::borderPen ( ) const

Get the background pen (border pen)

◆ borderRadius()

double QwtText::borderRadius ( ) const

Get the radius for the corners of the border frame.

◆ color()

QColor QwtText::color ( ) const

Get the pen color used for painting the text.

◆ draw()

void QwtText::draw ( QPainter *  painter,
const QRectF &  rect 
) const

Draw a text into a rectangle.

◆ font()

QFont QwtText::font ( ) const

Get the font.

◆ format()

QwtText::TextFormat QwtText::format ( ) const

Return the format of the text.

◆ heightForWidth() [1/2]

double QwtText::heightForWidth ( double  width) const

Find the height for a given width.

◆ heightForWidth() [2/2]

double QwtText::heightForWidth ( double  width,
const QFont &  defaultFont 
) const

Find the height for a given width.

◆ isEmpty()

bool QwtText::isEmpty ( ) const

Check if text is empty.

◆ isNull()

bool QwtText::isNull ( ) const

Check if text is null.

◆ operator!=()

bool QwtText::operator!= ( const QwtText other) const

Inequality operator.

◆ operator=()

QwtText & QwtText::operator= ( const QwtText other)

Assignment operator.

◆ operator==()

bool QwtText::operator== ( const QwtText other) const

Equality operator.

◆ renderFlags()

int QwtText::renderFlags ( ) const

Get render flags.

◆ setBackgroundBrush()

void QwtText::setBackgroundBrush ( const QBrush &  brush)

Set the background brush.

◆ setBorderPen()

void QwtText::setBorderPen ( const QPen &  pen)

Set the background pen (border pen)

◆ setBorderRadius()

void QwtText::setBorderRadius ( double  radius)

Set the radius for the corners of the border frame.

◆ setColor()

void QwtText::setColor ( const QColor &  color)

Set the pen color used for drawing the text.

◆ setFont()

void QwtText::setFont ( const QFont &  font)

Set the font.

◆ setLayoutAttribute()

void QwtText::setLayoutAttribute ( LayoutAttribute  attribute,
bool  on = true 
)

Change a layout attribute.

◆ setPaintAttribute()

void QwtText::setPaintAttribute ( PaintAttribute  attribute,
bool  on = true 
)

Change a paint attribute.

◆ setRenderFlags()

void QwtText::setRenderFlags ( int  renderFlags)

Change the render flags.

◆ setText()

void QwtText::setText ( const QString &  text,
QwtText::TextFormat  textFormat = AutoText 
)

Assign a new text content.

◆ setTextEngine()

void QwtText::setTextEngine ( QwtText::TextFormat  format,
QwtTextEngine engine 
)
static

Assign/Replace a text engine for a text format.

◆ testLayoutAttribute()

bool QwtText::testLayoutAttribute ( LayoutAttribute  attribute) const

Test a layout attribute.

◆ testPaintAttribute()

bool QwtText::testPaintAttribute ( PaintAttribute  attribute) const

Test a paint attribute.

◆ text()

QString QwtText::text ( ) const

Get text as QString.

◆ textEngine() [1/2]

const QwtTextEngine * QwtText::textEngine ( const QString &  text,
QwtText::TextFormat  format = AutoText 
)
static

Find the text engine for a text format.

◆ textEngine() [2/2]

const QwtTextEngine * QwtText::textEngine ( QwtText::TextFormat  format)
static

Find the text engine for a text format.

◆ textSize() [1/2]

QSizeF QwtText::textSize ( ) const

Returns the size that is needed to render text.

◆ textSize() [2/2]

QSizeF QwtText::textSize ( const QFont &  defaultFont) const

Returns the size that is needed to render text.

◆ usedColor()

QColor QwtText::usedColor ( const QColor &  defaultColor) const

Return the color of the text, if it has one, otherwise return defaultColor.

◆ usedFont()

QFont QwtText::usedFont ( const QFont &  defaultFont) const

Return the font of the text, if it has one, otherwise return defaultFont.


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