跳转至

QWT — Qt 绘图库

QWT(Qt Widgets for Technical Applications)是一个基于 Qt 的 2D/3D 绘图库,用于科学计算和工程应用中的数据可视化。

与其它 Qt 绘图库的比较

Qt 生态里能画图的库不多,主流的有 QCustomPlot、Qwt、Qt Charts 和 KDChart。Qt 6.8 之后把原来的 Qt Charts(2D)与 Qt DataVisualization(3D)合并为统一的 Qt Graphs 模块,底层全部基于 Qt Quick Scene Graph + Qt Quick 3D,放弃了老旧的 Graphics-View/QPainter 管线。不过 Qt Graphs 必须通过 QQuickWidget 或 QQuickWindow 嵌入,必须带 QML runtime,C++ 支持不足,且不支持 Win7 等老系统,对嵌入式也不友好。

库 协议 优势 劣势
QCustomPlot GPL 接口简单,使用广泛 GPL 要求开源,商业项目不便使用
Qwt LGPL 渲染速度快,架构清晰 原作者停止维护,部署较麻烦
Qt Charts GPL Qt 官方模块 渲染性能较低,GPL 协议
KDChart MIT (3.0+) 商业友好 渲染效果一般

本项目基于 Qwt 6.2.0 维护,保留原有架构,并加入 CMake 支持、Qt 6 兼容、单文件引入、3D 绘图和大数据量渲染等改进与修复。

Qwt 7.0 新特性

  • 支持 CMake:一行 find_package(qwt) 即可引入
  • 支持 Qt 6,兼容 Qt 5.12+ 和 Qt 6.x
  • 单文件引入:把 QwtPlot.h 和 QwtPlot.cpp 加入工程即可
  • 扁平化视觉风格,去掉旧版浮雕效果
  • Figure 容器,支持类似 matplotlib 的多绘图布局
  • 寄生轴架构,坐标轴数量不受限制
  • 坐标轴支持鼠标拖动和滚轮缩放
  • 内置 3D 绘图模块
  • 全面使用 C++11:override、nullptr、智能指针、范围 for 循环
  • 4 种曲线降采样算法与 SIMD 加速
  • 颜色循环系统,自动为系列分配颜色
  • QwtPlotBoxChart 箱线图,用于展示统计分布
  • 滑块、旋钮、刻度盘等控件支持扁平化样式

快速集成

使用 CMake(推荐):

1
2
3
4
find_package(qwt REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE qwt::plot)
# 3D 绘图
target_link_libraries(${PROJECT_NAME} PRIVATE qwt::plot3d)

使用单文件合并版本:

1
2
3
4
5
// 将 src-amalgamate/QwtPlot.h 和 QwtPlot.cpp 加入项目
#include "QwtPlot.h"

auto* plot = new QwtPlot("My Plot");
auto* curve = new QwtPlotCurve("Data");

项目地址

效果展示

基本图表

  • Figure Widget
    examples/2D/figure

  • Retained Grid
    examples/2D/figureGrid

  • Simple Plot
    examples/2D/simpleplot

  • Bar Chart
    examples/2D/barchart

  • Scatter Plot
    examples/2D/scatterplot

  • Curve Demo
    examples/2D/curvedemo

  • Box Chart
    examples/2D/boxchart

实时可视化

  • CPU Monitor
    examples/2D/cpuplot

  • Real-Time Plot
    examples/2D/realtime

  • Oscilloscope
    examples/2D/oscilloscope

  • Radio
    examples/2D/radio

  • Sysinfo
    examples/2D/sysinfo

  • Animated
    examples/2D/animation

高级图表

  • Spectrogram
    examples/2D/spectrogram

  • Vector Field
    playground/vectorfield

  • Stock Chart
    examples/2D/stockchart

  • Polar Demo
    examples/2D/polardemo

  • Parasite Plot
    examples/2D/parasitePlot

  • Bode Plot
    examples/2D/bode

  • Shapes
    playground/shapes

  • Scale Engine
    playground/scaleengine

  • PyPlot
    examples/2D/pyplot

其他示例

  • Distrowatch
    examples/2D/distrowatch

  • Friedberg Bar
    examples/2D/friedberg

  • Friedberg Tube
    examples/2D/friedberg

  • Item Editor
    examples/2D/itemeditor

  • Rasterview 1
    examples/2D/rasterview

  • Rasterview 2
    examples/2D/rasterview

  • Refresh Test
    examples/2D/refreshtest

  • Spline Editor
    examples/2D/splineeditor

  • TV Plot
    examples/2D/tvplot

  • Curve Tracker
    playground/curvetracker

  • Graphic Scale
    playground/graphicscale

  • Plot Matrix
    playground/plotmatrix

  • Rescaler
    playground/rescaler

  • SVG Map
    playground/svgmap

  • Time Scale
    playground/timescale

交互演示

  • Axis Pan
    坐标轴拖动

  • Axis Zoom
    坐标轴缩放

  • Figure Overlay
    Figure 交互蒙版

  • Series Data Picker
    数据拾取器

版权信息

Qwt 基于 Qwt License 1.0 发布,完整版权声明如下:

1
2
3
4
5
Qwt Widget Library
Copyright (C) 1997   Josef Wilgen
Copyright (C) 2002   Uwe Rathmann

Qwt is published under the Qwt License, Version 1.0.