QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
| Public 类型 | Public 成员函数 | 静态 Public 成员函数 | 所有成员列表
QwtText类 参考

A class representing a text 更多...

#include <qwt_text.h>

class  LayoutCache
 
class  PrivateData
 

Public 类型

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

Public 成员函数

 QwtText ()
 Default constructor
 
 QwtText (const QString &, TextFormat textFormat=AutoText)
 
 QwtText (const QwtText &)
 
 QwtText (QwtText &&) noexcept
 
 ~QwtText ()
 Destructor
 
QwtTextoperator= (const QwtText &)
 Assignment operator
 
QwtTextoperator= (QwtText &&) noexcept
 Move 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
 

静态 Public 成员函数

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
 

详细描述

A class representing a text

A QwtText is a text including a set of attributes how to render it.

参见
QwtTextEngine, QwtTextLabel

成员枚举类型说明

◆ LayoutAttribute

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

枚举值
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

Font and color and background are optional attributes of a QwtText. The paint attributes hold the information, if they are set.

枚举值
PaintUsingTextFont 

The text has an individual font.

PaintUsingTextColor 

The text has an individual color.

PaintBackground 

The text has an individual background.

◆ TextFormat

Text format

The text format defines the QwtTextEngine, that is used to render the text.

参见
QwtTextEngine, setTextEngine()
枚举值
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:110
static void setTextEngine(QwtText::TextFormat, QwtTextEngine *)
Assign/Replace a text engine for a text format
Definition qwt_text.cpp:787
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.

构造及析构函数说明

◆ QwtText()

QwtText::QwtText ( )

Default constructor

Constructor

参数
textText content
textFormatText format

Copy constructor

参数
otherOther QwtText to copy from

Move constructor

参数
otherOther QwtText to move from

成员函数说明

◆ backgroundBrush()

QBrush QwtText::backgroundBrush ( ) const

Get the background brush

返回
Background brush
参见
setBackgroundBrush(), borderPen()

◆ borderPen()

QPen QwtText::borderPen ( ) const

Get the background pen (border pen)

返回
Background pen
参见
setBorderPen(), backgroundBrush()

◆ borderRadius()

double QwtText::borderRadius ( ) const

Get the radius for the corners of the border frame

返回
Radius for the corners of the border frame
参见
setBorderRadius(), borderPen(), backgroundBrush()

◆ color()

QColor QwtText::color ( ) const

Get the pen color used for painting the text

返回
Current color
参见
setColor(), usedColor()

◆ draw()

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

Draw a text into a rectangle

参数
painterPainter
rectRectangle to draw text into
参见
textSize()

◆ font()

QFont QwtText::font ( ) const

Get the font

返回
Current font
参见
setFont(), usedFont()

◆ format()

QwtText::TextFormat QwtText::format ( ) const

Return the format of the text

返回
The format of the text
注解
This function was introduced in QWT7.0

◆ heightForWidth() [1/2]

double QwtText::heightForWidth ( double  width) const

Find the height for a given width

参数
widthWidth
返回
Calculated height
参见
heightForWidth(double, const QFont&)

◆ heightForWidth() [2/2]

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

Find the height for a given width

参数
widthWidth
defaultFontFont used for the calculation if the text has no font
返回
Calculated height
参见
heightForWidth(double)

◆ isEmpty()

bool QwtText::isEmpty ( ) const

Check if text is empty

返回
text().isEmpty()

◆ isNull()

bool QwtText::isNull ( ) const

Check if text is null

返回
text().isNull()

◆ operator!=()

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

Inequality operator

参数
otherOther QwtText to compare with
返回
true if not equal

◆ operator=() [1/2]

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

Assignment operator

参数
otherOther QwtText to assign from
返回
Reference to this QwtText

◆ operator=() [2/2]

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

Move assignment operator

参数
otherOther QwtText to move from
返回
Reference to this QwtText

◆ operator==()

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

Equality operator

参数
otherOther QwtText to compare with
返回
true if equal

◆ renderFlags()

int QwtText::renderFlags ( ) const

Get render flags

返回
Render flags
参见
setRenderFlags()

◆ setBackgroundBrush()

void QwtText::setBackgroundBrush ( const QBrush &  brush)

Set the background brush

参数
brushBackground brush
参见
backgroundBrush(), setBorderPen()

◆ setBorderPen()

void QwtText::setBorderPen ( const QPen &  pen)

Set the background pen (border pen)

参数
penBackground pen
参见
borderPen(), setBackgroundBrush()

◆ setBorderRadius()

void QwtText::setBorderRadius ( double  radius)

Set the radius for the corners of the border frame

参数
radiusRadius of a rounded corner
参见
borderRadius(), setBorderPen(), setBackgroundBrush()

◆ setColor()

void QwtText::setColor ( const QColor &  color)

Set the pen color used for drawing the text

参数
colorColor to set
注解
Setting the color might have no effect, when the text contains control sequences for setting colors.
参见
color(), usedColor()

◆ setFont()

void QwtText::setFont ( const QFont &  font)

Set the font

参数
fontFont to set
注解
Setting the font might have no effect, when the text contains control sequences for setting fonts.
参见
font(), usedFont()

◆ setLayoutAttribute()

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

Change a layout attribute

参数
attributeLayout attribute to change
onOn/Off
参见
testLayoutAttribute()

◆ setPaintAttribute()

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

Change a paint attribute

参数
attributePaint attribute to change
onOn/Off
注解
Used by setFont(), setColor(), setBorderPen() and setBackgroundBrush()
参见
testPaintAttribute()

◆ setRenderFlags()

void QwtText::setRenderFlags ( int  renderFlags)

Change the render flags

The default setting is Qt::AlignCenter

参数
renderFlagsBitwise OR of the flags used like in QPainter::drawText()
参见
renderFlags(), QwtTextEngine::draw()
注解
Some renderFlags might have no effect, depending on the text format.

◆ setText()

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

Assign a new text content

参数
textText content
textFormatText format
参见
text()

◆ setTextEngine()

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

Assign/Replace a text engine for a text format

With setTextEngine it is possible to extend Qwt with other types of text formats. For QwtText::PlainText it is not allowed to assign a engine == nullptr.

参数
formatText format
engineText engine
警告
Using QwtText::AutoText does nothing.
参见
textEngine(QwtText::TextFormat)

◆ testLayoutAttribute()

bool QwtText::testLayoutAttribute ( LayoutAttribute  attribute) const

Test a layout attribute

参数
attributeLayout attribute to test
返回
true, if attribute is enabled
参见
setLayoutAttribute()

◆ testPaintAttribute()

bool QwtText::testPaintAttribute ( PaintAttribute  attribute) const

Test a paint attribute

参数
attributePaint attribute to test
返回
true, if attribute is enabled
参见
setPaintAttribute()

◆ text()

QString QwtText::text ( ) const

Get text as QString

返回
Text as QString
参见
setText()

◆ textEngine() [1/2]

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

Find the text engine for a text format

In case of QwtText::AutoText the first text engine (beside QwtPlainTextEngine) is returned, where QwtTextEngine::mightRender returns true. If there is none QwtPlainTextEngine is returned. If no text engine is registered for the format QwtPlainTextEngine is returned.

参数
textText, needed in case of AutoText
formatText format
返回
Corresponding text engine
参见
textEngine(QwtText::TextFormat)

◆ textEngine() [2/2]

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

Find the text engine for a text format

textEngine can be used to find out if a text format is supported.

参数
formatText format
返回
The text engine, or nullptr if no engine is available.
参见
textEngine(const QString&, QwtText::TextFormat)

◆ textSize() [1/2]

QSizeF QwtText::textSize ( ) const

Returns the size that is needed to render text

返回
Calculated size
参见
textSize(const QFont&)

◆ textSize() [2/2]

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

Returns the size that is needed to render text

参数
defaultFontFont of the text
返回
Calculated size
参见
textSize()

◆ usedColor()

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

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

参数
defaultColorDefault color to use if text has no color
返回
Color used for drawing the text
参见
setColor(), color(), PaintAttributes

◆ usedFont()

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

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

参数
defaultFontDefault font to use if text has no font
返回
Font used for drawing the text
参见
setFont(), font(), PaintAttributes

该类的文档由以下文件生成: