Q3DTheme Class

Q3DTheme class provides a visual style for graphs. More...

Header: #include <Q3DTheme>
Since: QtDataVisualization 1.0
Instantiated By: Theme3D
Inherits: QObject

Public Types

enum ColorStyle { ColorStyleUniform, ColorStyleObjectGradient, ColorStyleRangeGradient }
enum Theme { ThemeQt, ThemePrimaryColors, ThemeDigia, ThemeStoneMoss, ..., ThemeUserDefined }

Properties

  • 1 property inherited from QObject

Public Functions

Q3DTheme(QObject *parent = Q_NULLPTR)
Q3DTheme(Theme themeType, QObject *parent = Q_NULLPTR)
virtual ~Q3DTheme()
float ambientLightStrength() const
QColor backgroundColor() const
QList<QColor> baseColors() const
QList<QLinearGradient> baseGradients() const
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(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(Theme themeType)
void setWindowColor(const QColor &color)
QColor singleHighlightColor() const
QLinearGradient singleHighlightGradient() const
Theme type() const
QColor windowColor() const
  • 31 public functions inherited from QObject

Signals

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)

Additional Inherited Members

  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 10 static public members inherited from QObject
  • 9 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

Q3DTheme class provides a visual style for graphs.

Q3DTheme is used to specify visual properties that affect the whole graph. There are several built-in themes that can be used directly, or be modified freely. User can also create a theme from scratch using ThemeUserDefined. Creating a theme using the default constructor produces a new user-defined theme.

Properties controlled by theme

PropertyEffectDefault in ThemeUserDefined
ambientLightStrengthThe strength of the ambient light in the graph. This affects how evenly and brightly the colors are shown throughout the graph regardless of light position.0.25
backgroundColorColor of the graph background.Qt::black
backgroundEnabledIs the graph background drawn or not.true
baseColorsList of colors for the objects in the graph. Colors are applied to series one by one. If there are more series than colors, the color list is reused from the start. The colors in this property are used if colorStyle is ColorStyleUniform. This can be overridden by setting the baseColor explicitly in series.Qt::black
baseGradientsList of gradients for the objects in the graph. Gradients are applied to series one by one. If there are more series than gradients, the gradient list is reused from the start. The gradients in this property are used if colorStyle is ColorStyleObjectGradient or ColorStyleRangeGradient. This can be overridden by setting the baseGradient explicitly in series.QLinearGradient(). Essentially fully black.
colorStyleThe color style of the objects in the graph. See ColorStyle for detailed description of the styles. This can be overridden by setting the colorStyle explicitly in series.ColorStyleUniform
fontThe font to be used for labels.QFont()
gridEnabledIs the grid on the background drawn or not. This affects all grid lines.true
gridLineColorThe color for the grid lines.Qt::white
highlightLightStrengthThe specular light strength for highlighted objects.7.5
labelBackgroundColorThe color of the label background. This property has no effect if labelBackgroundEnabled is false.Qt::gray
labelBackgroundEnabledAre the labels to be drawn with a background using labelBackgroundColor (including alpha), or with a fully transparent background. Labels with background are drawn to equal sizes per axis based on the longest label, and the text is centered in it. Labels without background are drawn as is and are left/right aligned based on their position in the graph.true
labelBorderEnabledAre the labels to be drawn with a border or not. This property affects only labels with a background.true
labelTextColorThe color for the font used in labels.Qt::white
lightColorThe color of the light. Affects both ambient and specular light.Qt::white
lightStrengthThe strength of the specular light in the graph. This affects the light specified in Q3DScene.5.0
multiHighlightColorThe color to be used for highlighted objects, if selectionMode of the graph has QAbstract3DGraph::SelectionRow or QAbstract3DGraph::SelectionColumn flag set.Qt::blue
multiHighlightGradientThe gradient to be used for highlighted objects, if selectionMode of the graph has QAbstract3DGraph::SelectionRow or QAbstract3DGraph::SelectionColumn flag set.QLinearGradient(). Essentially fully black.
singleHighlightColorThe color to be used for a highlighted object, if selectionMode of the graph has QAbstract3DGraph::SelectionItem flag set.Qt::red
singleHighlightGradientThe gradient to be used for a highlighted object, if selectionMode of the graph has QAbstract3DGraph::SelectionItem flag set.QLinearGradient(). Essentially fully black.
windowColorThe color of the window the graph is drawn into.Qt::black

Usage examples

Creating a built-in theme without any modifications:


  Q3DTheme *theme = new Q3DTheme(Q3DTheme::ThemeQt);

Creating a built-in theme and modifying some properties:


  Q3DTheme *theme = new Q3DTheme(Q3DTheme::ThemeQt);
  theme->setBackgroundEnabled(false);
  theme->setLabelBackgroundEnabled(false);

Creating a user-defined theme:


  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)));

Creating a built-in theme and modifying some properties after it has been set:


  Q3DBars *graph = new Q3DBars();
  graph->activeTheme()->setType(Q3DTheme::ThemePrimaryColors);
  graph->activeTheme()->setBaseColor(Qt::red);
  graph->activeTheme()->setSingleHighlightColor(Qt::yellow);

Member Type Documentation

enum Q3DTheme::ColorStyle

Color styles.

ConstantValueDescription
Q3DTheme::ColorStyleUniform0Objects are rendered in a single color. The color used is specified in baseColors, singleHighlightColor and multiHighlightColor properties.
Q3DTheme::ColorStyleObjectGradient1Objects are colored using a full gradient for each object regardless of object height. The gradient used is specified in baseGradients, singleHighlightGradient and multiHighlightGradient properties.
Q3DTheme::ColorStyleRangeGradient2Objects are colored using a portion of the full gradient determined by the object's height and its position on the Y-axis. The gradient used is specified in baseGradients, singleHighlightGradient and multiHighlightGradient properties.

enum Q3DTheme::Theme

Built-in themes.

ConstantValueDescription
Q3DTheme::ThemeQt0A light theme with green as the base color.
Q3DTheme::ThemePrimaryColors1A light theme with yellow as the base color.
Q3DTheme::ThemeDigia2A light theme with gray as the base color.
Q3DTheme::ThemeStoneMoss3A medium dark theme with yellow as the base color.
Q3DTheme::ThemeArmyBlue4A medium light theme with blue as the base color.
Q3DTheme::ThemeRetro5A medium light theme with brown as the base color.
Q3DTheme::ThemeEbony6A dark theme with white as the base color.
Q3DTheme::ThemeIsabelle7A dark theme with yellow as the base color.
Q3DTheme::ThemeUserDefined8A user-defined theme. See Properties controlled by theme for theme defaults.

Property Documentation

ambientLightStrength : float

Ambient light strength for the whole graph. Value must be between 0.0f and 1.0f.

Access functions:

float ambientLightStrength() const
void setAmbientLightStrength(float strength)

Notifier signal:

void ambientLightStrengthChanged(float strength)

backgroundColor : QColor

Color for the graph background.

Access functions:

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

Notifier signal:

void backgroundColorChanged(const QColor &color)

backgroundEnabled : bool

Set background enabled or disabled.

Access functions:

bool isBackgroundEnabled() const
void setBackgroundEnabled(bool enabled)

Notifier signal:

void backgroundEnabledChanged(bool enabled)

baseColors : QList<QColor>

List of base colors to be used for all the objects in the graph, series by series. If there are more series than colors, color list wraps and starts again with the first color in the list. Has no immediate effect if colorStyle is not ColorStyleUniform.

Access functions:

QList<QColor> baseColors() const
void setBaseColors(const QList<QColor> &colors)

Notifier signal:

void baseColorsChanged(const QList<QColor> &colors)

baseGradients : QList<QLinearGradient>

List of base gradients to be used for all the objects in the graph, series by series. If there are more series than gradients, gradient list wraps and starts again with the first gradient in the list Has no immediate effect if colorStyle is ColorStyleUniform.

Access functions:

QList<QLinearGradient> baseGradients() const
void setBaseGradients(const QList<QLinearGradient> &gradients)

Notifier signal:

void baseGradientsChanged(const QList<QLinearGradient> &gradients)

colorStyle : ColorStyle

The style of the graph colors. One of ColorStyle.

Access functions:

ColorStyle colorStyle() const
void setColorStyle(ColorStyle style)

Notifier signal:

void colorStyleChanged(Q3DTheme::ColorStyle style)

font : QFont

Set font to be used for labels.

Access functions:

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

Notifier signal:

void fontChanged(const QFont &font)

gridEnabled : bool

Set grid lines enabled or disabled.

Access functions:

bool isGridEnabled() const
void setGridEnabled(bool enabled)

Notifier signal:

void gridEnabledChanged(bool enabled)

gridLineColor : QColor

Color for the grid lines.

Access functions:

QColor gridLineColor() const
void setGridLineColor(const QColor &color)

Notifier signal:

void gridLineColorChanged(const QColor &color)

highlightLightStrength : float

Specular light strength for highlighted objects. Value must be between 0.0f and 10.0f.

Access functions:

float highlightLightStrength() const
void setHighlightLightStrength(float strength)

Notifier signal:

void highlightLightStrengthChanged(float strength)

labelBackgroundColor : QColor

Color for the label backgrounds. Has no effect if labelBackgroundEnabled is false.

Access functions:

QColor labelBackgroundColor() const
void setLabelBackgroundColor(const QColor &color)

Notifier signal:

void labelBackgroundColorChanged(const QColor &color)

labelBackgroundEnabled : bool

Set label backgrounds enabled or disabled.

Access functions:

bool isLabelBackgroundEnabled() const
void setLabelBackgroundEnabled(bool enabled)

Notifier signal:

void labelBackgroundEnabledChanged(bool enabled)

labelBorderEnabled : bool

Set label borders enabled or disabled. Has no effect if labelBackgroundEnabled is false.

Access functions:

bool isLabelBorderEnabled() const
void setLabelBorderEnabled(bool enabled)

Notifier signal:

void labelBorderEnabledChanged(bool enabled)

labelTextColor : QColor

Color for the font used for labels.

Access functions:

QColor labelTextColor() const
void setLabelTextColor(const QColor &color)

Notifier signal:

void labelTextColorChanged(const QColor &color)

lightColor : QColor

Color for the specular light defined in Q3DScene.

Access functions:

QColor lightColor() const
void setLightColor(const QColor &color)

Notifier signal:

void lightColorChanged(const QColor &color)

lightStrength : float

Specular light strength for the whole graph. Value must be between 0.0f and 10.0f.

Access functions:

float lightStrength() const
void setLightStrength(float strength)

Notifier signal:

void lightStrengthChanged(float strength)

multiHighlightColor : QColor

Highlight color for highlighted objects. Used if selectionMode has QAbstract3DGraph::SelectionRow or QAbstract3DGraph::SelectionColumn flag set.

Access functions:

QColor multiHighlightColor() const
void setMultiHighlightColor(const QColor &color)

Notifier signal:

void multiHighlightColorChanged(const QColor &color)

multiHighlightGradient : QLinearGradient

Highlight gradient for highlighted objects. Used if selectionMode has QAbstract3DGraph::SelectionRow or QAbstract3DGraph::SelectionColumn flag set.

Access functions:

QLinearGradient multiHighlightGradient() const
void setMultiHighlightGradient(const QLinearGradient &gradient)

Notifier signal:

void multiHighlightGradientChanged(const QLinearGradient &gradient)

singleHighlightColor : QColor

Highlight color for a highlighted object. Used if selectionMode has QAbstract3DGraph::SelectionItem flag set.

Access functions:

QColor singleHighlightColor() const
void setSingleHighlightColor(const QColor &color)

Notifier signal:

void singleHighlightColorChanged(const QColor &color)

singleHighlightGradient : QLinearGradient

Highlight gradient for a highlighted object. Used if selectionMode has QAbstract3DGraph::SelectionItem flag set.

Access functions:

QLinearGradient singleHighlightGradient() const
void setSingleHighlightGradient(const QLinearGradient &gradient)

Notifier signal:

void singleHighlightGradientChanged(const QLinearGradient &gradient)

type : Theme

The type of the theme. The type is automatically set when constructing a theme, but can also be changed later. Changing the theme type will change all other properties of the theme to what the predefined theme specifies. Changing the theme type of the active theme of the graph will also reset all attached series to use the new theme.

Access functions:

Theme type() const
void setType(Theme themeType)

Notifier signal:

void typeChanged(Q3DTheme::Theme themeType)

windowColor : QColor

Color for the application window.

Access functions:

QColor windowColor() const
void setWindowColor(const QColor &color)

Notifier signal:

void windowColorChanged(const QColor &color)

Member Function Documentation

Q3DTheme::Q3DTheme(QObject *parent = Q_NULLPTR)

Constructs a new theme of type ThemeUserDefined. An optional parent parameter can be given and is then passed to QObject constructor.

Q3DTheme::Q3DTheme(Theme themeType, QObject *parent = Q_NULLPTR)

Constructs a new theme with themeType, which can be one of the built-in themes from Theme. An optional parent parameter can be given and is then passed to QObject constructor.

[virtual] Q3DTheme::~Q3DTheme()

Destroys the theme.