QTextInlineObject Class

QTextInlineObject 类表示QAbstractTextDocumentLayout 中的内联对象及其实现。更多

头文件: #include <QTextInlineObject>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui

注意:该类中的所有函数都是可重入的

公共函数

qreal ascent() const
qreal descent() const
QTextFormat format() const
int formatIndex() const
qreal height() const
bool isValid() const
QRectF rect() const
void setAscent(qreal a)
void setDescent(qreal d)
void setWidth(qreal w)
Qt::LayoutDirection textDirection() const
int textPosition() const
qreal width() const

详细说明

通常,您不需要创建 QTextInlineObject。QAbstractTextDocumentLayout 用于在实现自定义布局时处理内联对象。

内联对象有多种属性可以设置,例如使用setWidth(),setAscent(), 和setDescent() 。它占据的矩形区域由rect() 给出,方向由textDirection() 给出。它在文本布局中的位置由textPosition() 确定,格式由format() 确定。

成员函数文档

qreal QTextInlineObject::ascent() const

返回内联对象的上升。

另请参见 setAscent()、descent()、width() 和rect()。

qreal QTextInlineObject::descent() const

返回内联对象的下降值。

另请参阅 setDescent()、ascent()、width() 和rect() 。

QTextFormat QTextInlineObject::format() const

返回文本布局中内联对象的格式。

int QTextInlineObject::formatIndex() const

返回一个整数,说明文本布局中内联对象的格式。

qreal QTextInlineObject::height() const

返回内联对象的总高度。等于ascent() +descent() + 1。

另请参阅 ascent()、descent()、width() 和rect()。

bool QTextInlineObject::isValid() const

如果该内联对象有效,则返回true ;否则返回 false。

QRectF QTextInlineObject::rect() const

返回内联对象的矩形。

另请参阅 ascent()、descent() 和width()。

void QTextInlineObject::setAscent(qreal a)

将内联对象的上升沿设置为a

另请参阅 ascent()、setDescent()、width() 和rect() 。

void QTextInlineObject::setDescent(qreal d)

将内联对象的后裔设置为d

另请参阅 descent()、setAscent()、width() 和rect() 。

void QTextInlineObject::setWidth(qreal w)

将内联对象的宽度设置为w

另请参阅 width(),ascent(),descent() 和rect().

Qt::LayoutDirection QTextInlineObject::textDirection() const

返回对象的布局是从右到左还是从左到右。

int QTextInlineObject::textPosition() const

内联对象在文本布局中的位置。

qreal QTextInlineObject::width() const

返回内联对象的宽度。

另请参阅 setWidth()、ascent()、descent() 和rect() 。

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