本页内容

Qt3DExtras::QText2DEntity Class

class Qt3DExtras::QText2DEntity

QText2DEntity 允许在 3D 空间中创建 2D 文本。更多内容...

标题: #include <Qt3DExtras/QText2DEntity>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3dextras)
target_link_libraries(mytarget PRIVATE Qt6::3dextras)
qmake: QT += 3dextras
在 QML 中: Text2DEntity
继承自: Qt3DCore::QEntity
状态: 已弃用

该类已弃用。我们强烈建议不要在新代码中使用它。

属性

公共函数

Qt::Alignment alignment() const
QColor color() const
QFont font() const
float height() const
void setAlignment(Qt::Alignment alignment)
void setColor(const QColor &color)
void setFont(const QFont &font)
void setHeight(float height)
void setText(const QString &text)
void setWidth(float width)
QString text() const
float width() const

信号

void colorChanged(const QColor &color)
void fontChanged(const QFont &font)
void heightChanged(float height)
void textChanged(const QString &text)
void widthChanged(float width)

详细说明

QText2DEntity 将文本渲染为 XY 平面上的三角形。几何图形将适配于指定宽度和高度的矩形内。如果生成的几何图形宽度超过指定宽度,则超出部分将渲染在新行上。

可以通过添加一个变换组件来在场景中定位该实体。

QText2DEntity 将根据字形的形状创建几何体,并使用指定的颜色创建实心材质。

属性文档

alignment : Qt::Alignment

返回在Qt Quick 场景中显示的文本项的对齐方式。

默认对齐方式为左上对齐。

访问函数:

Qt::Alignment alignment() const
void setAlignment(Qt::Alignment alignment)

color : QColor

存储在Qt Quick 场景中显示的文本项的颜色。

访问函数:

QColor color() const
void setColor(const QColor &color)

通知信号:

void colorChanged(const QColor &color)

font : QFont

存储在Qt Quick 场景中显示的文本项所使用的字体。

访问函数:

QFont font() const
void setFont(const QFont &font)

通知器信号:

void fontChanged(const QFont &font)

height : float

返回在Qt Quick 场景中显示的文本项的高度。

访问函数:

float height() const
void setHeight(float height)

通知器信号:

void heightChanged(float height)

text : QString

存储在Qt Quick 场景中显示的文本。

访问函数:

QString text() const
void setText(const QString &text)

通知信号:

void textChanged(const QString &text)

width : float

返回在Qt Quick 场景中显示的文本项的宽度。

访问函数:

float width() const
void setWidth(float width)

通知信号:

void widthChanged(float width)

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