本页内容

QCustom3DLabel Class

QCustom3DLabel 类用于在图中添加自定义标签。更多内容...

头文件: #include <QCustom3DLabel>
CMake: find_package(Qt6 REQUIRED COMPONENTS DataVisualization)
target_link_libraries(mytarget PRIVATE Qt6::DataVisualization)
qmake: QT += datavisualization
自: QtDataVisualization 1.1
在 QML 中: Custom3DLabel
继承自: QCustom3DItem
状态: 已弃用

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

属性

公共函数

QCustom3DLabel(QObject *parent = nullptr)
QCustom3DLabel(const QString &text, const QFont &font, const QVector3D &position, const QVector3D &scaling, const QQuaternion &rotation, QObject *parent = nullptr)
virtual ~QCustom3DLabel()
QColor backgroundColor() const
QFont font() const
bool isBackgroundEnabled() const
bool isBorderEnabled() const
bool isFacingCamera() const
void setBackgroundColor(const QColor &color)
void setBackgroundEnabled(bool enabled)
void setBorderEnabled(bool enabled)
void setFacingCamera(bool enabled)
void setFont(const QFont &font)
void setText(const QString &text)
void setTextColor(const QColor &color)
QString text() const
QColor textColor() const

信号

void backgroundColorChanged(const QColor &color)
void backgroundEnabledChanged(bool enabled)
void borderEnabledChanged(bool enabled)
void facingCameraChanged(bool enabled)
void fontChanged(const QFont &font)
void textChanged(const QString &text)
void textColorChanged(const QColor &color)

详细说明

可以设置自定义标签的文本、字体、位置、缩放比例、旋转角度和颜色。此外,还可以切换标签边框和背景的显示状态。除非显式设置,否则颜色、边框和背景由当前主题决定。

注意:在 缩放操作中 ,z坐标不产生影响。将x坐标和y坐标设置为相同值可保留原始字体尺寸。

另请参阅 QAbstract3DGraph::addCustomItem()。

属性文档

backgroundColor : QColor

如果启用了该属性,它将指定标签背景的颜色。

默认值为Qt::gray 。

访问函数:

QColor backgroundColor() const
void setBackgroundColor(const QColor &color)

通知信号:

void backgroundColorChanged(const QColor &color)

另请参阅 backgroundEnabled 。

backgroundEnabled : bool

该属性控制标签背景是否启用。

如果设置为false ,则backgroundColor()将不起作用。默认值为true 。

访问函数:

bool isBackgroundEnabled() const
void setBackgroundEnabled(bool enabled)

通知信号:

void backgroundEnabledChanged(bool enabled)

borderEnabled : bool

该属性控制是否启用标签边框。

默认值为true 。

访问函数:

bool isBorderEnabled() const
void setBorderEnabled(bool enabled)

通知信号:

void borderEnabledChanged(bool enabled)

facingCamera : bool

该属性控制标签是否始终朝向摄像头。

默认值为false 。若设置为true ,则rotation()将无效。

访问函数:

bool isFacingCamera() const
void setFacingCamera(bool enabled)

通知信号:

void facingCameraChanged(bool enabled)

font : QFont

此属性用于指定标签所使用的字体。

默认值为QFont("Arial", 20) 。不支持特殊格式(例如,带轮廓)。

访问函数:

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

通知信号:

void fontChanged(const QFont &font)

text : QString

此属性用于存储标签的文本。

不支持富文本。

访问函数:

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

通知信号:

void textChanged(const QString &text)

textColor : QColor

此属性用于设置标签文本的颜色。

如果启用了边框,该属性也会影响标签的边框。默认值为Qt::white 。

访问函数:

QColor textColor() const
void setTextColor(const QColor &color)

通知信号:

void textColorChanged(const QColor &color)

另请参阅 borderEnabled 。

成员函数文档

[explicit] QCustom3DLabel::QCustom3DLabel(QObject *parent = nullptr)

使用给定的parent 构建一个自定义的3D标签。

[explicit] QCustom3DLabel::QCustom3DLabel(const QString &text, const QFont &font, const QVector3D &position, const QVector3D &scaling, const QQuaternion &rotation, QObject *parent = nullptr)

根据给定的text 、font 、position 、scaling 、rotation 以及可选的parent ,构建一个自定义的3D标签。

注意: 为scaling 设置 相同的x和y坐标可保留原始字体尺寸。

[virtual noexcept] QCustom3DLabel::~QCustom3DLabel()

删除自定义的 3D 标签。

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