QCustom3DLabel Class
QCustom3DLabel 类为图形添加自定义标签。更多
Header: | #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) |
Notifier 信号:
void | backgroundColorChanged(const QColor &color) |
另请参阅 backgroundEnabled 。
backgroundEnabled : bool
此属性表示是否启用标签背景。
如果设置为false
,则backgroundColor() 无效。默认为true
。
访问功能:
bool | isBackgroundEnabled() const |
void | setBackgroundEnabled(bool enabled) |
Notifier 信号:
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) |
Notifier 信号:
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 标签。
© 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.