- Qt 6.12
- Qt Graphs
- C++ Classes
- QtGraphs
- QCustom3DLabel
- Qt Graphs | Commercial or GPLv3

# QCustom3DLabel Class

The QCustom3DLabel class adds a custom label to a graph. More...

Header: | `#include <QCustom3DLabel>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Graphs)` `target_link_libraries(mytarget PRIVATE Qt6::Graphs)`
qmake: | `QT += graphs`
In QML: | Custom3DLabel
Inherits: | QCustom3DItem

- List of all members, including inherited members
- QCustom3DLabel is part of Qt Graphs C++ Classes for 3D.

## Properties

backgroundColor : QColor backgroundVisible : bool borderVisible : bool facingCamera : bool | font : QFont text : QString textColor : QColor

## Public Functions

| 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

## Signals

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)

## Detailed Description

The text, font, position, scaling, rotation, and colors of a custom label can be set. In addition, the visibility of the borders and background of the label can be toggled. Colors, borders, and background are determined by the active theme unless set explicitly.

Note: In scaling, the z-coordinate has no effect. Setting the same x- and y-coordinates retains the original font dimensions.

See also Q3DGraphsWidgetItem::addCustomItem().

## Property Documentation

### backgroundColor : QColor

This property holds the color for the label background, if enabled.

Defaults to `Qt::gray`.

Access functions:

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

Notifier signal:

void | backgroundColorChanged(QColor color)

See also backgroundVisible.

### backgroundVisible : bool

This property holds whether the label background is visible.

If set to `false`, backgroundColor() has no effect. Defaults to `true`.

Access functions:

bool | isBackgroundVisible() const
void | setBackgroundVisible(bool visible)

Notifier signal:

void | backgroundVisibleChanged(bool visible)

### borderVisible : bool

This property holds whether label borders are visible.

Defaults to `true`.

Access functions:

bool | isBorderVisible() const
void | setBorderVisible(bool visible)

Notifier signal:

void | borderVisibleChanged(bool visible)

### facingCamera : bool

This property holds whether the label will always face the camera.

Defaults to `false`. If set to `true`, rotation() has no effect.

Access functions:

bool | isFacingCamera() const
void | setFacingCamera(bool enabled)

Notifier signal:

void | facingCameraChanged(bool enabled)

### font : QFont

This property holds the font to be used for the label.

Defaults to `QFont("Arial", 20)`. Special formatting (for example, outlined) is not supported.

Access functions:

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

Notifier signal:

void | fontChanged(const QFont &font)

### text : QString

This property holds the text for the label.

Rich text is not supported.

Access functions:

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

Notifier signal:

void | textChanged(const QString &text)

### textColor : QColor

This property holds the color for the label text.

Also affects the label border, if enabled. Defaults to `Qt::white`.

Access functions:

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

Notifier signal:

void | textColorChanged(QColor color)

See also borderVisible.

## Member Function Documentation

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

Constructs a custom 3D label with the given parent.

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

Constructs a custom 3D label with the given text, font, position, scaling, rotation, and optional parent.

Note: Setting the same x- and y-coordinates for scaling retains the original font dimensions.

### `[override virtual noexcept]` QCustom3DLabel::~QCustom3DLabel()

Deletes the custom 3D label.