QCustom3DLabel Class
QCustom3DLabel 类可在图上添加自定义标签。更多内容...
| 头文件: | #include <QCustom3DLabel> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Graphs) target_link_libraries(mytarget PRIVATE Qt6::Graphs) |
| qmake: | QT += graphs |
| 在 QML 中: | Custom3DLabel |
| 继承自: | QCustom3DItem |
- 所有成员列表(包括继承的成员)
- QCustom3DLabel 属于Qt Graphs 的3D C++ 类库。
属性
|
公共函数
| QCustom3DLabel(QObject *parent = nullptr) | |
| QCustom3DLabel(const QString &text, const QFont &font, QVector3D position, QVector3D scaling, const QQuaternion &rotation, QObject *parent = nullptr) | |
| virtual | ~QCustom3DLabel() override |
| QColor | backgroundColor() const |
| QFont | font() const |
| bool | isBackgroundVisible() const |
| bool | isBorderVisible() const |
| bool | isFacingCamera() const |
| void | setBackgroundColor(QColor color) |
| void | setBackgroundVisible(bool visible) |
| void | setBorderVisible(bool visible) |
| void | setFacingCamera(bool enabled) |
| void | setFont(const QFont &font) |
| void | setText(const QString &text) |
| void | setTextColor(QColor color) |
| QString | text() const |
| QColor | textColor() const |
信号
| void | backgroundColorChanged(QColor color) |
| void | backgroundVisibleChanged(bool visible) |
| void | borderVisibleChanged(bool visible) |
| void | facingCameraChanged(bool enabled) |
| void | fontChanged(const QFont &font) |
| void | textChanged(const QString &text) |
| void | textColorChanged(QColor color) |
详细说明
可以设置自定义标签的文本、字体、位置、缩放比例、旋转角度和颜色。此外,还可以切换标签边框和背景的显示状态。除非显式设置,否则颜色、边框和背景由当前主题决定。
注意:在 缩放操作中 ,z 坐标不产生影响。将 x 和 y 坐标设置为相同值可保留原始字体尺寸。
另请参阅 Q3DGraphsWidgetItem::addCustomItem()。
属性文档
backgroundColor : QColor
如果启用了该选项,此属性将指定标签背景的颜色。
默认值为Qt::gray 。
访问函数:
| QColor | backgroundColor() const |
| void | setBackgroundColor(QColor color) |
通知信号:
| void | backgroundColorChanged(QColor color) |
另请参阅 backgroundVisible 。
backgroundVisible : bool
该属性控制标签背景是否可见。
如果设置为false ,backgroundColor() 将无效。默认值为true 。
访问函数:
| bool | isBackgroundVisible() const |
| void | setBackgroundVisible(bool visible) |
通知器信号:
| void | backgroundVisibleChanged(bool visible) |
borderVisible : bool
该属性控制标签边框是否可见。
默认值为true 。
访问函数:
| bool | isBorderVisible() const |
| void | setBorderVisible(bool visible) |
通知信号:
| void | borderVisibleChanged(bool visible) |
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(QColor color) |
通知信号:
| void | textColorChanged(QColor color) |
另请参阅 borderVisible 。
成员函数文档
[explicit] QCustom3DLabel::QCustom3DLabel(QObject *parent = nullptr)
使用给定的parent 构建一个自定义的3D标签。
[explicit] QCustom3DLabel::QCustom3DLabel(const QString &text, const QFont &font, QVector3D position, QVector3D scaling, const QQuaternion &rotation, QObject *parent = nullptr)
根据给定的text 、font 、position 、scaling 、rotation 以及可选的parent ,构建一个自定义的3D标签。
注意: 为scaling 设置 相同的x和y坐标可保留原始字体尺寸。
[override 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.