QTextItem Class

The QTextItem class provides all the information required to draw text in a custom paint engine. More...

Header: #include <QTextItem>
qmake: QT += gui

Public Types

enum RenderFlag { RightToLeft, Overline, Underline, StrikeOut }
flags RenderFlags

Public Functions

qreal ascent() const
qreal descent() const
QFont font() const
RenderFlags renderFlags() const
QString text() const
qreal width() const

Detailed Description

The QTextItem class provides all the information required to draw text in a custom paint engine.

When you reimplement your own paint engine, you must reimplement QPaintEngine::drawTextItem(), a function that takes a QTextItem as one of its arguments.

Member Type Documentation

enum QTextItem::RenderFlag
flags QTextItem::RenderFlags

ConstantValueDescription
QTextItem::RightToLeft0x1Render the text from right to left.
QTextItem::Overline0x10Paint a line above the text.
QTextItem::Underline0x20Paint a line under the text.
QTextItem::StrikeOut0x40Paint a line through the text.

The RenderFlags type is a typedef for QFlags<RenderFlag>. It stores an OR combination of RenderFlag values.

Member Function Documentation

qreal QTextItem::ascent() const

Corresponds to the ascent of the piece of text that is drawn.

qreal QTextItem::descent() const

Corresponds to the descent of the piece of text that is drawn.

QFont QTextItem::font() const

Returns the font that should be used to draw the text.

RenderFlags QTextItem::renderFlags() const

Returns the render flags used.

QString QTextItem::text() const

Returns the text that should be drawn.

qreal QTextItem::width() const

Specifies the total width of the text to be drawn.

© 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.