Qwt plot utility classes collection and compatibility functions
This file provides two main features:
- Forward includes for plot utility classes: Including this file gives access to all Qwt plot utility classes at once. These utility classes replace the deprecated Qwt::plotItemColor() function with more powerful and type-safe functionality.
- Qt version compatibility function: qwtExpandedToGlobalStrut() handles the globalStrut API difference between Qt 5 and Qt 6, primarily used internally by Qwt widget classes.
Plot Utility Classes
Since Qwt 7.x, the following 5 dedicated utility classes are recommended for working with plot items:
- QwtPlotFactory: Factory methods for creating plot items (curves, bars, markers, etc.)
- QwtPlotItemInfo: Type queries for determining item types and basic information
- QwtPlotDataAccess: Data access for reading and writing plot item data
- QwtPlotTransform: Coordinate transformations between pixel and data coordinates
- QwtPlotStyling: Style operations for getting/setting colors, pens, brushes, etc.
All classes are in the Qwt namespace and provide type-safe, rtti-dispatched APIs that are safer and more efficient than the old dynamic_cast approach.
Example
}
QwtPlotStyling::setPenWidth(curve, 2.0);
QPointF plotPos = QwtPlotTransform::toPlotCoordinates(plot, screenPos);
Definition qwt_clipper.h:41
A plot item, that represents a series of points
Definition qwt_plot_curve.h:75
static QVector< QPointF > xySamples(const QwtPlotItem *item)
Extract XY samples from a plot item
Definition qwt_plot_data_access.cpp:48
static QwtPlotCurve * createCurve(QwtPlot *plot, const QString &title, const QVector< QPointF > &data, QwtAxisId xAxis=QwtAxis::XBottom, QwtAxisId yAxis=QwtAxis::YLeft)
Create a curve from QPointF data and attach it to a plot
Definition qwt_plot_factory.cpp:46
static bool isSeriesItem(const QwtPlotItem *item)
Check whether the item is a QwtPlotSeriesItem subclass
Definition qwt_plot_item_info.cpp:31
static bool setColor(QwtPlotItem *item, const QColor &color)
Set the color of a plot item
Definition qwt_plot_styling.cpp:93
A 2-D plotting widget
Definition qwt_plot.h:99
Qwt plot utility classes collection and compatibility functions
Guide
If you were using Qwt::plotItemColor(), you should now use QwtPlotStyling::color():
QColor color = Qwt::plotItemColor(item);
static QColor color(const QwtPlotItem *item, const QColor &defaultColor=QColor())
Get the representative color of a plot item
Definition qwt_plot_styling.cpp:38
The new approach supports more plot item types and uses rtti dispatch instead of dynamic_cast for better performance.
- 注解
- The qwtExpandedToGlobalStrut() function is retained for internal Qwt use only. Application code should not call this function directly.
| QSize QWT_EXPORT qwtExpandedToGlobalStrut |
( |
const QSize & |
size | ) |
|
Expand a size to the global strut (Qt5/Qt6 compatibility function)
In Qt 5.0-5.14, QApplication::globalStrut() returns the application-defined minimum widget size. This function expands the given size to at least that minimum size.
In Qt 5.15+ and Qt 6, globalStrut() has been removed and this function returns the original size unchanged.
- 参数
-
- 返回
- Size expanded to the global strut, or the original size on Qt 5.15+/Qt 6