QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
QwtPlotStyling Class Reference

Utility class for reading and writing visual style properties of QwtPlotItem. More...

#include <qwt_plot_styling.h>

Static Public Member Functions

static QColor color (const QwtPlotItem *item, const QColor &defaultColor=QColor())
 Get the representative color of a plot item.
 
static bool setColor (QwtPlotItem *item, const QColor &color)
 Set the color of a plot item.
 
static QPen pen (const QwtPlotItem *item)
 Get the pen of a plot item.
 
static bool setPen (QwtPlotItem *item, const QPen &pen)
 Set the pen of a plot item.
 
static QBrush brush (const QwtPlotItem *item)
 Get the brush of a plot item.
 
static bool setBrush (QwtPlotItem *item, const QBrush &brush)
 Set the brush of a plot item.
 
static void setSymbol (QwtPlotCurve *curve, QwtSymbol::Style style, const QSize &size=QSize(8, 8))
 Set a symbol on a curve with style and size.
 
static void setSymbol (QwtPlotCurve *curve, QwtSymbol::Style style, const QColor &color, const QSize &size=QSize(8, 8))
 Set a symbol on a curve with style, color and size.
 
static void setLineStyle (QwtPlotCurve *curve, Qt::PenStyle style, qreal width=0.0)
 Set curve line pen style and width.
 
static qreal recommendPenWidth (int pointCount)
 Recommend a pen width based on the number of data points.
 
static void forceReplot (QwtPlot *plot)
 Force an immediate replot even when autoReplot is disabled.
 

Detailed Description

Utility class for reading and writing visual style properties of QwtPlotItem.

QwtPlotStyling provides type-safe static methods to get or set the color, pen, brush, and symbol of any QwtPlotItem, dispatching through the item's rtti to call the correct type-specific API.

Also provides convenience methods for common styling operations such as setting a curve's symbol or recommending pen widths based on data density.

QwtPlotItem* item = ...;
// Get color regardless of item type
QColor c = Qwt::QwtPlotStyling::color(item);
// Set color uniformly
Qwt::QwtPlotStyling::setColor(item, Qt::red);
// Add a symbol to a curve
Qwt::QwtPlotStyling::setSymbol(curve, QwtSymbol::Ellipse, Qt::blue, QSize(6, 6));
Base class for items on the plot canvas.
Definition qwt_plot_item.h:85
@ Ellipse
Ellipse or circle.
Definition qwt_symbol.h:63
See also
QwtPlotItemInfo, QwtPlotDataAccess

Member Function Documentation

◆ brush()

QBrush QwtPlotStyling::brush ( const QwtPlotItem item)
static

Get the brush of a plot item.

Parameters
itemPlot item to query
Returns
The primary brush of the item, or a default QBrush if not recognized

◆ color()

QColor QwtPlotStyling::color ( const QwtPlotItem item,
const QColor &  defaultColor = QColor() 
)
static

Get the representative color of a plot item.

Parameters
itemPlot item to query
defaultColorColor to return if the item type is not recognized
Returns
The primary color of the item (from pen or brush)

Uses the item's rtti to dispatch to the correct type-specific API. For curves, returns the pen color; for bar charts, the brush color; for grids, the major pen color; etc.

◆ forceReplot()

void QwtPlotStyling::forceReplot ( QwtPlot plot)
static

Force an immediate replot even when autoReplot is disabled.

Parameters
plotTarget plot

Temporarily enables ImmediatePaint on the canvas (if it is a QwtPlotCanvas), performs a replot, and restores the previous paint attributes.

◆ pen()

QPen QwtPlotStyling::pen ( const QwtPlotItem item)
static

Get the pen of a plot item.

Parameters
itemPlot item to query
Returns
The primary pen of the item, or a default QPen if not recognized

◆ recommendPenWidth()

qreal QwtPlotStyling::recommendPenWidth ( int  pointCount)
static

Recommend a pen width based on the number of data points.

Parameters
pointCountNumber of data points in the series
Returns
Recommended pen width

For large datasets (>10000 points), a thinner pen improves rendering performance and visual clarity. For small datasets, a wider pen provides better visibility.

◆ setBrush()

bool QwtPlotStyling::setBrush ( QwtPlotItem item,
const QBrush &  brush 
)
static

Set the brush of a plot item.

Parameters
itemPlot item to modify
brushNew brush to apply
Returns
true if the brush was successfully applied

◆ setColor()

bool QwtPlotStyling::setColor ( QwtPlotItem item,
const QColor &  color 
)
static

Set the color of a plot item.

Parameters
itemPlot item to modify
colorNew color to apply
Returns
true if the color was successfully applied

For curves, sets the pen color; for bar charts and histograms, sets both pen color and brush color; for grids, sets the major pen color.

◆ setLineStyle()

void QwtPlotStyling::setLineStyle ( QwtPlotCurve curve,
Qt::PenStyle  style,
qreal  width = 0.0 
)
static

Set curve line pen style and width.

Parameters
curveTarget curve
stylePen style (solid, dashed, dotted, etc.)
widthPen width (0 = cosmetic)

◆ setPen()

bool QwtPlotStyling::setPen ( QwtPlotItem item,
const QPen &  pen 
)
static

Set the pen of a plot item.

Parameters
itemPlot item to modify
penNew pen to apply
Returns
true if the pen was successfully applied

◆ setSymbol() [1/2]

void QwtPlotStyling::setSymbol ( QwtPlotCurve curve,
QwtSymbol::Style  style,
const QColor &  color,
const QSize &  size = QSize(8, 8) 
)
static

Set a symbol on a curve with style, color and size.

Parameters
curveTarget curve
styleSymbol style
colorSymbol fill color
sizeSymbol size in pixels

◆ setSymbol() [2/2]

void QwtPlotStyling::setSymbol ( QwtPlotCurve curve,
QwtSymbol::Style  style,
const QSize &  size = QSize(8, 8) 
)
static

Set a symbol on a curve with style and size.

Parameters
curveTarget curve
styleSymbol style (ellipse, rect, diamond, etc.)
sizeSymbol size in pixels

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