Importing the QWT Library¶
Direct Import¶
Direct import simply requires adding QwtPlot.h and QwtPlot.cpp to your project.
Here is a CMake example for direct import:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
Tip
Since Qwt 7.1, the qwtplot3d library has been merged, so OpenGL-related dependencies are required.
Importing the QWT Library via CMake¶
This is the recommended way to import the
QWTlibrary.
First, it is not recommended to add the entire QWT library as a subproject to your project. Instead, build and install it locally first. For build and installation instructions, refer to: QWT Build Instructions
To import the QWT library via CMake, follow these steps:
1. Specify the QWT Installation Directory¶
Set the qwt_DIR variable to the lib/cmake/qwt path under the installation directory. (When CMake executes find_package(xx), it first checks whether an xx_DIR variable exists. If so, it looks for the corresponding xxConfig.cmake file under xx_DIR.)
Tip
If you use the default installation directory, you can skip setting the qwt_DIR variable — CMake will find it automatically.
For example:
1 | |
2. Use find_package to Load the Library¶
QWT provides standard CMake configuration files and can be imported via the find_package command.
1 2 3 4 5 6 7 | |
The qwt project provides three modules:
coremodule — shared base library containing 28 modules of foundational utilities:- Color utilities:
QwtColorMap(and subclasses),QwtColorCycle,QwtColorMapPreset(22 scientific colormap presets) - Math utilities:
qwt_math.h,qwtSimdArgMinMax(SIMD-accelerated argmin/argmax) - Data types:
QwtInterval,QwtPoint3D,QwtPointPolar,QwtSamples,QwtBoxStatistics - Geometry:
QwtBezier(Bézier curves),QwtClipper(polygon clipping) - Coordinate transforms:
QwtTransform,QwtScaleMap,QwtScaleDiv,QwtScaleEngine - Date/Time:
QwtDate,QwtSystemClock - Algorithms & compatibility:
qwt_algorithm.hpp,qwt_qt5qt6_compat.hpp(Qt5/Qt6 compatibility layer) - Data containers/series/raster:
QwtGridData,QwtSeriesData,QwtPointData,QwtSeriesStore,QwtRasterData,QwtMatrixRasterData,QwtGridRasterData
- Color utilities:
plotmodule — the 2D plotting library, integrating the original Qwt functionalityplot3dmodule — the 3D plotting library, integrating the qwtplot3d functionality
1 2 3 4 5 6 7 8 | |
Dependency Notes
Both
plotandplot3ddepend on thecoremodule, but are independent of each other.
qwt::coredepends only on QtCore+Guiqwt::plotdepends on QtCore+Gui+Widgets(public);Concurrent+PrintSupport(private). Optional:SvgandOpenGL/OpenGLWidgets(gated byQWT_CONFIG_QWTSVG/QWT_CONFIG_QWTOPENGL). All dependencies are added automatically when importing via CMake.qwt::plot3ddepends on QtCore+Gui+Widgets+OpenGL::GLU+ Qt OpenGL WidgetsIf the 3D option is enabled, the
OpenGL::GLUdependency is automatically included.
Public Predefined Macros¶
QWT uses several predefined macros during compilation. If you manage your project with CMake, these macros are automatically defined when loading the library via find_package — no manual configuration is needed.
However, if you use an IDE such as Visual Studio to manually import the library, you need to specify the predefined macros in addition to adding the lib files. When importing the qwtcore library, you need the predefined macro QWTCORE_DLL. When importing the qwtplot library compiled as a DLL, you need the predefined macro QWT_DLL. When importing the qwtplot3d library, you need the predefined macro QWT3D_DLL.
Tip
As a modern C++ project, it is strongly recommended to use CMake to build your project. All these predefined macros are pre-configured in the CMake configuration.