QCustom3DLabel Class
QCustom3DLabel 类为图形添加自定义标签。更多
Header: | #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 C++ Classes for 3D 的一部分。
属性
|
公共功能
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) |
Notifier 信号:
void | backgroundColorChanged(QColor color) |
另请参阅 backgroundVisible 。
backgroundVisible : bool
该属性表示标签背景是否可见。
如果设置为false
,则backgroundColor() 无效。默认为true
。
访问功能:
bool | isBackgroundVisible() const |
void | setBackgroundVisible(bool visible) |
Notifier 信号:
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) |
Notifier 信号:
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 标签。
© 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.