QTextItem Class

QTextItem 类提供了在自定义绘制引擎中绘制文本所需的所有信息。更多

Header: #include <QTextItem>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui

公共类型

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

公共函数

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

详细说明

当您重新实现自己的绘画引擎时,您必须重新实现QPaintEngine::drawTextItem() 函数,该函数将 QTextItem 作为参数之一。

成员类型文档

枚举 QTextItem::RenderFlag
flags QTextItem::RenderFlags

常量说明
QTextItem::RightToLeft0x1从右向左渲染文本。
QTextItem::Overline0x10在文本上方绘制一行。
QTextItem::Underline0x20在文字下方画一行。
QTextItem::StrikeOut0x40在文本中画一条横线。

RenderFlags 类型是QFlags<RenderFlag> 的类型定义。它存储 RenderFlag 值的 OR 组合。

成员函数文档

qreal QTextItem::ascent() const

对应于所绘制文本的ascent

qreal QTextItem::descent() const

对应于所绘制文本的descent

QFont QTextItem::font() const

返回用于绘制文本的字体。

QTextItem::RenderFlags QTextItem::renderFlags() const

返回使用的渲染标记。

QString QTextItem::text() const

返回应绘制的文本。

qreal QTextItem::width() const

指定要绘制文字的总宽度。

© 2025 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.