Q3DTheme Class
La clase Q3DTheme proporciona un estilo visual para los gráficos. Más...
| Cabecera: | #include <Q3DTheme> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS DataVisualization)target_link_libraries(mytarget PRIVATE Qt6::DataVisualization) |
| qmake: | QT += datavisualization |
| Desde: | QtDataVisualization 1.0 |
| En QML: | Theme3D |
| Hereda: | QObject |
Tipos Públicos
| enum | ColorStyle { ColorStyleUniform, ColorStyleObjectGradient, ColorStyleRangeGradient } |
| enum | Theme { ThemeQt, ThemePrimaryColors, ThemeDigia, ThemeStoneMoss, ThemeArmyBlue, …, ThemeUserDefined } |
Propiedades
|
|
Funciones públicas
| Q3DTheme(QObject *parent = nullptr) | |
| Q3DTheme(Q3DTheme::Theme themeType, QObject *parent = nullptr) | |
| virtual | ~Q3DTheme() |
| float | ambientLightStrength() const |
| QColor | backgroundColor() const |
| QList<QColor> | baseColors() const |
| QList<QLinearGradient> | baseGradients() const |
| Q3DTheme::ColorStyle | colorStyle() const |
| QFont | font() const |
| QColor | gridLineColor() const |
| float | highlightLightStrength() const |
| bool | isBackgroundEnabled() const |
| bool | isGridEnabled() const |
| bool | isLabelBackgroundEnabled() const |
| bool | isLabelBorderEnabled() const |
| QColor | labelBackgroundColor() const |
| QColor | labelTextColor() const |
| QColor | lightColor() const |
| float | lightStrength() const |
| QColor | multiHighlightColor() const |
| QLinearGradient | multiHighlightGradient() const |
| void | setAmbientLightStrength(float strength) |
| void | setBackgroundColor(const QColor &color) |
| void | setBackgroundEnabled(bool enabled) |
| void | setBaseColors(const QList<QColor> &colors) |
| void | setBaseGradients(const QList<QLinearGradient> &gradients) |
| void | setColorStyle(Q3DTheme::ColorStyle style) |
| void | setFont(const QFont &font) |
| void | setGridEnabled(bool enabled) |
| void | setGridLineColor(const QColor &color) |
| void | setHighlightLightStrength(float strength) |
| void | setLabelBackgroundColor(const QColor &color) |
| void | setLabelBackgroundEnabled(bool enabled) |
| void | setLabelBorderEnabled(bool enabled) |
| void | setLabelTextColor(const QColor &color) |
| void | setLightColor(const QColor &color) |
| void | setLightStrength(float strength) |
| void | setMultiHighlightColor(const QColor &color) |
| void | setMultiHighlightGradient(const QLinearGradient &gradient) |
| void | setSingleHighlightColor(const QColor &color) |
| void | setSingleHighlightGradient(const QLinearGradient &gradient) |
| void | setType(Q3DTheme::Theme themeType) |
| void | setWindowColor(const QColor &color) |
| QColor | singleHighlightColor() const |
| QLinearGradient | singleHighlightGradient() const |
| Q3DTheme::Theme | type() const |
| QColor | windowColor() const |
Señales
| void | ambientLightStrengthChanged(float strength) |
| void | backgroundColorChanged(const QColor &color) |
| void | backgroundEnabledChanged(bool enabled) |
| void | baseColorsChanged(const QList<QColor> &colors) |
| void | baseGradientsChanged(const QList<QLinearGradient> &gradients) |
| void | colorStyleChanged(Q3DTheme::ColorStyle style) |
| void | fontChanged(const QFont &font) |
| void | gridEnabledChanged(bool enabled) |
| void | gridLineColorChanged(const QColor &color) |
| void | highlightLightStrengthChanged(float strength) |
| void | labelBackgroundColorChanged(const QColor &color) |
| void | labelBackgroundEnabledChanged(bool enabled) |
| void | labelBorderEnabledChanged(bool enabled) |
| void | labelTextColorChanged(const QColor &color) |
| void | lightColorChanged(const QColor &color) |
| void | lightStrengthChanged(float strength) |
| void | multiHighlightColorChanged(const QColor &color) |
| void | multiHighlightGradientChanged(const QLinearGradient &gradient) |
| void | singleHighlightColorChanged(const QColor &color) |
| void | singleHighlightGradientChanged(const QLinearGradient &gradient) |
| void | typeChanged(Q3DTheme::Theme themeType) |
| void | windowColorChanged(const QColor &color) |
Descripción Detallada
Especifica las propiedades visuales que afectan a todo el gráfico. Hay varios temas incorporados que pueden utilizarse tal cual o modificarse libremente.
Las siguientes propiedades pueden anularse utilizando las propiedades QAbstract3DSeries para establecerlas explícitamente en la serie: baseColors, baseGradients, y colorStyle.
Los temas pueden crearse desde cero utilizando el valor enum ThemeUserDefined. La creación de un tema utilizando el constructor por defecto produce un nuevo tema definido por el usuario.
Tema por defecto
La siguiente tabla enumera las propiedades controladas por temas y los valores por defecto para ThemeUserDefined.
| Propiedad | Valor por defecto |
|---|---|
| ambientLightStrength | 0.25 |
| backgroundColor | Qt::black |
| backgroundEnabled | true |
| baseColors | Qt::black |
| baseGradients | QLinearGradient. Totalmente negro. |
| colorStyle | ColorStyleUniform |
| font | QFont |
| gridEnabled | true |
| gridLineColor | Qt::white |
| highlightLightStrength | 7.5 |
| labelBackgroundColor | Qt::gray |
| labelBackgroundEnabled | true |
| labelBorderEnabled | true |
| labelTextColor | Qt::white |
| lightColor | Qt::white |
| lightStrength | 5.0 |
| multiHighlightColor | Qt::blue |
| multiHighlightGradient | QLinearGradient. Esencialmente negro. |
| singleHighlightColor | Qt::red |
| singleHighlightGradient | QLinearGradient. Esencialmente negro. |
| windowColor | Qt::black |
Ejemplos de uso
Creación de un tema incorporado sin ninguna modificación:
Creación de un tema incorporado y modificación de algunas propiedades:
Q3DTheme *theme = new Q3DTheme(Q3DTheme::ThemeQt); theme->setBackgroundEnabled(false); theme->setLabelBackgroundEnabled(false);
Creación de un tema definido por el usuario:
Q3DTheme *theme = new Q3DTheme(); theme->setAmbientLightStrength(0.3f); theme->setBackgroundColor(QColor(QRgb(0x99ca53))); theme->setBackgroundEnabled(true); theme->setBaseColor(QColor(QRgb(0x209fdf))); theme->setColorStyle(Q3DTheme::ColorStyleUniform); theme->setFont(QFont(QStringLiteral("Impact"), 35)); theme->setGridEnabled(true); theme->setGridLineColor(QColor(QRgb(0x99ca53))); theme->setHighlightLightStrength(7.0f); theme->setLabelBackgroundColor(QColor(0xf6, 0xa6, 0x25, 0xa0)); theme->setLabelBackgroundEnabled(true); theme->setLabelBorderEnabled(true); theme->setLabelTextColor(QColor(QRgb(0x404044))); theme->setLightColor(Qt::white); theme->setLightStrength(6.0f); theme->setMultiHighlightColor(QColor(QRgb(0x6d5fd5))); theme->setSingleHighlightColor(QColor(QRgb(0xf6a625))); theme->setWindowColor(QColor(QRgb(0xffffff)));
Creación de un tema incorporado y modificación de algunas propiedades una vez definido:
Documentación de los tipos de miembros
enum Q3DTheme::ColorStyle
Estilos de color.
| Constante | Valor | Descripción |
|---|---|---|
Q3DTheme::ColorStyleUniform | 0 | Los objetos se representan en un único color. El color utilizado se especifica en las propiedades baseColors, singleHighlightColor y multiHighlightColor. |
Q3DTheme::ColorStyleObjectGradient | 1 | Los objetos se colorean utilizando un gradiente completo para cada objeto, independientemente de su altura. El gradiente utilizado se especifica en las propiedades baseGradients, singleHighlightGradient y multiHighlightGradient. |
Q3DTheme::ColorStyleRangeGradient | 2 | Los objetos se colorean utilizando una parte del degradado completo determinada por la altura del objeto y su posición en el eje Y. El gradiente utilizado se especifica en las propiedades baseGradients, singleHighlightGradient y multiHighlightGradient. |
enum Q3DTheme::Theme
Temas incorporados.
| Constante | Valor | Descripción |
|---|---|---|
Q3DTheme::ThemeQt | 0 | Un tema claro con verde como color base. |
Q3DTheme::ThemePrimaryColors | 1 | Un tema claro con amarillo como color base. |
Q3DTheme::ThemeDigia | 2 | Tema claro con gris como color base. |
Q3DTheme::ThemeStoneMoss | 3 | Tema medio oscuro con amarillo como color base. |
Q3DTheme::ThemeArmyBlue | 4 | Tema medio claro con azul como color base. |
Q3DTheme::ThemeRetro | 5 | Un tema medio claro con marrón como color base. |
Q3DTheme::ThemeEbony | 6 | Un tema oscuro con blanco como color base. |
Q3DTheme::ThemeIsabelle | 7 | Un tema oscuro con amarillo como color base. |
Q3DTheme::ThemeUserDefined | 8 | Un tema definido por el usuario. Para más información, consulte Default Theme. |
Documentación de propiedades
ambientLightStrength : float
Esta propiedad contiene la intensidad de la luz ambiental para todo el gráfico.
Este valor determina la uniformidad y el brillo con que se muestran los colores en todo el gráfico, independientemente de la posición de la luz.
El valor debe estar comprendido entre 0.0f y 1.0f.
Funciones de acceso:
| float | ambientLightStrength() const |
| void | setAmbientLightStrength(float strength) |
Señal del notificador:
| void | ambientLightStrengthChanged(float strength) |
backgroundColor : QColor
Esta propiedad contiene el color del fondo del gráfico.
Funciones de acceso:
| QColor | backgroundColor() const |
| void | setBackgroundColor(const QColor &color) |
Señal del notificador:
| void | backgroundColorChanged(const QColor &color) |
backgroundEnabled : bool
Esta propiedad indica si el fondo es visible.
El fondo se dibuja utilizando el valor de backgroundColor.
Funciones de acceso:
| bool | isBackgroundEnabled() const |
| void | setBackgroundEnabled(bool enabled) |
Señal del notificador:
| void | backgroundEnabledChanged(bool enabled) |
baseColors : QList<QColor>
Esta propiedad contiene la lista de colores base que se utilizarán para todos los objetos del gráfico, serie por serie.
Si hay más series que colores, la lista de colores se envuelve y comienza de nuevo con el primer color de la lista.
No tiene efecto inmediato si colorStyle no es ColorStyleUniform.
Este valor puede anularse configurando baseColor explícitamente en la serie.
Funciones de acceso:
| QList<QColor> | baseColors() const |
| void | setBaseColors(const QList<QColor> &colors) |
Señal de aviso:
| void | baseColorsChanged(const QList<QColor> &colors) |
baseGradients : QList<QLinearGradient>
Esta propiedad contiene la lista de degradados base que se utilizarán para todos los objetos del gráfico, serie por serie.
Si hay más series que gradientes, la lista de gradientes se envuelve y comienza de nuevo con el primer gradiente de la lista
No tiene efecto inmediato si colorStyle es ColorStyleUniform.
Este valor puede anularse estableciendo baseGradient explícitamente en la serie.
Funciones de acceso:
| QList<QLinearGradient> | baseGradients() const |
| void | setBaseGradients(const QList<QLinearGradient> &gradients) |
Señal de aviso:
| void | baseGradientsChanged(const QList<QLinearGradient> &gradients) |
colorStyle : ColorStyle
Esta propiedad contiene el estilo de los colores del gráfico.
Uno de los valores del enum ColorStyle.
Este valor puede anularse estableciendo colorStyle explícitamente en la serie.
Funciones de acceso:
| Q3DTheme::ColorStyle | colorStyle() const |
| void | setColorStyle(Q3DTheme::ColorStyle style) |
Señal del notificador:
| void | colorStyleChanged(Q3DTheme::ColorStyle style) |
font : QFont
Esta propiedad contiene el tipo de letra que se utilizará para las etiquetas.
Funciones de acceso:
| QFont | font() const |
| void | setFont(const QFont &font) |
Señal del notificador:
| void | fontChanged(const QFont &font) |
gridEnabled : bool
Esta propiedad indica si se dibujan las líneas de la rejilla.
Este valor afecta a todas las líneas de la rejilla.
Funciones de acceso:
| bool | isGridEnabled() const |
| void | setGridEnabled(bool enabled) |
Señal del notificador:
| void | gridEnabledChanged(bool enabled) |
gridLineColor : QColor
Esta propiedad contiene el color de las líneas de la rejilla.
Nota: La transparencia no está soportada y provocará un comportamiento indefinido.
Funciones de acceso:
| QColor | gridLineColor() const |
| void | setGridLineColor(const QColor &color) |
Señal del notificador:
| void | gridLineColorChanged(const QColor &color) |
highlightLightStrength : float
Esta propiedad contiene la intensidad de la luz especular para los objetos seleccionados.
El valor debe estar comprendido entre 0.0f y 10.0f.
Funciones de acceso:
| float | highlightLightStrength() const |
| void | setHighlightLightStrength(float strength) |
Señal del notificador:
| void | highlightLightStrengthChanged(float strength) |
labelBackgroundColor : QColor
Esta propiedad contiene el color del fondo de las etiquetas.
No tiene efecto si labelBackgroundEnabled es false.
Funciones de acceso:
| QColor | labelBackgroundColor() const |
| void | setLabelBackgroundColor(const QColor &color) |
Señal del notificador:
| void | labelBackgroundColorChanged(const QColor &color) |
labelBackgroundEnabled : bool
Esta propiedad indica si la etiqueta se dibuja con un fondo de color o con un fondo totalmente transparente.
El valor labelBackgroundColor (incluyendo alfa) se utiliza para dibujar el fondo.
Las etiquetas con fondo se dibujan con tamaños iguales por eje en función de la etiqueta más larga, y el texto se centra en ellas. Las etiquetas sin fondo se dibujan tal cual y se alinean a la izquierda o a la derecha en función de su posición en el gráfico.
Funciones de acceso:
| bool | isLabelBackgroundEnabled() const |
| void | setLabelBackgroundEnabled(bool enabled) |
Señal del notificador:
| void | labelBackgroundEnabledChanged(bool enabled) |
labelBorderEnabled : bool
Esta propiedad determina si se dibujan los bordes de las etiquetas que tienen fondo.
No tiene efecto si labelBackgroundEnabled es false.
Funciones de acceso:
| bool | isLabelBorderEnabled() const |
| void | setLabelBorderEnabled(bool enabled) |
Señal del notificador:
| void | labelBorderEnabledChanged(bool enabled) |
labelTextColor : QColor
Esta propiedad contiene el color de la fuente utilizada para las etiquetas.
Funciones de acceso:
| QColor | labelTextColor() const |
| void | setLabelTextColor(const QColor &color) |
Señal del notificador:
| void | labelTextColorChanged(const QColor &color) |
lightColor : QColor
Esta propiedad contiene el color para la luz ambiental y especular.
Este valor afecta a la luz especificada en Q3DScene.
Funciones de acceso:
| QColor | lightColor() const |
| void | setLightColor(const QColor &color) |
Señal del notificador:
| void | lightColorChanged(const QColor &color) |
lightStrength : float
Esta propiedad contiene la intensidad de la luz especular para todo el gráfico.
El valor debe estar entre 0.0f y 10.0f.
Este valor afecta a la luz especificada en Q3DScene.
Funciones de acceso:
| float | lightStrength() const |
| void | setLightStrength(float strength) |
Señal notificadora:
| void | lightStrengthChanged(float strength) |
multiHighlightColor : QColor
Esta propiedad contiene el color de resaltado de los objetos seleccionados.
Se utiliza si selectionMode tiene activado el indicador QAbstract3DGraph::SelectionRow o QAbstract3DGraph::SelectionColumn.
Funciones de acceso:
| QColor | multiHighlightColor() const |
| void | setMultiHighlightColor(const QColor &color) |
Señal del notificador:
| void | multiHighlightColorChanged(const QColor &color) |
multiHighlightGradient : QLinearGradient
Esta propiedad contiene el gradiente de resaltado de los objetos seleccionados.
Se utiliza si selectionMode tiene activado el indicador QAbstract3DGraph::SelectionRow o QAbstract3DGraph::SelectionColumn.
Funciones de acceso:
| QLinearGradient | multiHighlightGradient() const |
| void | setMultiHighlightGradient(const QLinearGradient &gradient) |
Señal del notificador:
| void | multiHighlightGradientChanged(const QLinearGradient &gradient) |
singleHighlightColor : QColor
Esta propiedad contiene el color de resaltado de un objeto seleccionado.
Se utiliza si selectionMode tiene activada la opción QAbstract3DGraph::SelectionItem.
Funciones de acceso:
| QColor | singleHighlightColor() const |
| void | setSingleHighlightColor(const QColor &color) |
Señal del notificador:
| void | singleHighlightColorChanged(const QColor &color) |
singleHighlightGradient : QLinearGradient
Esta propiedad contiene el gradiente de resaltado de un objeto seleccionado.
Se utiliza si selectionMode tiene activada la opción QAbstract3DGraph::SelectionItem.
Funciones de acceso:
| QLinearGradient | singleHighlightGradient() const |
| void | setSingleHighlightGradient(const QLinearGradient &gradient) |
Señal del notificador:
| void | singleHighlightGradientChanged(const QLinearGradient &gradient) |
type : Theme
Esta propiedad contiene el tipo del tema.
El tipo se establece automáticamente cuando se construye un tema, pero también puede cambiarse posteriormente. Al cambiar el tipo de tema, todas las demás propiedades del tema cambiarán a lo que especifique el tema predefinido. Al cambiar el tipo de tema del tema activo del gráfico también se restablecerán todas las series adjuntas para que utilicen el nuevo tema.
Funciones de acceso:
| Q3DTheme::Theme | type() const |
| void | setType(Q3DTheme::Theme themeType) |
Señal de aviso:
| void | typeChanged(Q3DTheme::Theme themeType) |
windowColor : QColor
Esta propiedad contiene el color de la ventana de la aplicación en la que se dibuja el gráfico.
Funciones de acceso:
| QColor | windowColor() const |
| void | setWindowColor(const QColor &color) |
Señal del notificador:
| void | windowColorChanged(const QColor &color) |
Documentación de funciones miembro
[explicit] Q3DTheme::Q3DTheme(QObject *parent = nullptr)
Construye un nuevo tema de tipo ThemeUserDefined. Se puede dar un parámetro opcional parent que se pasa al constructor QObject.
[explicit] Q3DTheme::Q3DTheme(Q3DTheme::Theme themeType, QObject *parent = nullptr)
Construye un nuevo tema con themeType, que puede ser uno de los temas incorporados de Theme. Se puede dar un parámetro opcional parent que se pasa al constructor QObject.
[virtual noexcept] Q3DTheme::~Q3DTheme()
Destruye el tema.
© 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.