QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
静态 Public 成员函数 | 所有成员列表
QwtPlotStyling类 参考

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

#include <qwt_plot_styling.h>

静态 Public 成员函数

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
 

详细描述

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
参见
QwtPlotItemInfo, QwtPlotDataAccess

成员函数说明

◆ brush()

QBrush QwtPlotStyling::brush ( const QwtPlotItem item)
static

Get the brush of a plot item

参数
itemPlot item to query
返回
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

参数
itemPlot item to query
defaultColorColor to return if the item type is not recognized
返回
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

参数
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

参数
itemPlot item to query
返回
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

参数
pointCountNumber of data points in the series
返回
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

参数
itemPlot item to modify
brushNew brush to apply
返回
true if the brush was successfully applied

◆ setColor()

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

Set the color of a plot item

参数
itemPlot item to modify
colorNew color to apply
返回
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

参数
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

参数
itemPlot item to modify
penNew pen to apply
返回
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

参数
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

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

该类的文档由以下文件生成: