Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
PlotTheme Class Reference

Applies the active theme's palette to a QCustomPlot. More...

#include <plot_theme.h>

Static Public Member Functions

static void apply (QCustomPlot *plot)
 Recolor a plot from the current theme.
static void applyToAxis (QCPAxis *axis)
 Recolor one axis from the current theme.
static void track (QCustomPlot *plot, std::function< void()> afterApply=nullptr)
 Apply the theme now and again whenever the theme changes.
static QColor textColor ()
 The theme's primary text color for plot elements.

Detailed Description

Applies the active theme's palette to a QCustomPlot.

QCustomPlot defaults to a white background with black axes, which is unreadable in dark themes. This helper recolors the background, axes, grids, legend and titles from the theme tokens and keeps them current across theme switches.

Member Function Documentation

◆ apply()

void PlotTheme::apply ( QCustomPlot * plot)
static

Recolor a plot from the current theme.

Pen widths and styles are preserved. Does not replot.

Parameters
plotThe plot to recolor.

◆ applyToAxis()

void PlotTheme::applyToAxis ( QCPAxis * axis)
static

Recolor one axis from the current theme.

Recolors the axis' pens, labels, grid, sub-grid and zero line. Use it for axes created after apply() or track() ran. Pen widths and styles are preserved. Null-safe. Does not replot.

Parameters
axisThe axis to recolor.

◆ textColor()

QColor PlotTheme::textColor ( )
static

The theme's primary text color for plot elements.

Returns
The PaletteText token color.

◆ track()

void PlotTheme::track ( QCustomPlot * plot,
std::function< void()> afterApply = nullptr )
static

Apply the theme now and again whenever the theme changes.

Calls apply(), then afterApply, then replots, immediately and on every ThemeManager::themeChanged. The connection is bound to the plot's lifetime.

Parameters
plotThe plot to track.
afterApplyOptional hook for plot-specific colors that must be reapplied after the generic recoloring.

The documentation for this class was generated from the following files: