跳转至

QWT — Qt 绘图库

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

为什么选择 QWT?

Qt 生态里能画图的库不多,主流的有 QCustomPlotQwtQt ChartsKDChart。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 进行维护和改进,添加了现代化功能和修复,使其成为协议友好、性能优越、方便使用的 Qt 绘图库。

Qwt 7.0 新特性

  • CMake 支持find_package(qwt) 一键引入
  • 支持 Qt6 — 兼容 Qt 5.12+ 和 Qt 6.x
  • 单一文件引入 — 类似 QCustomPlot,只需 QwtPlot.h + QwtPlot.cpp
  • 美化控件风格 — 去除老旧浮雕风格,现代化 UI
  • Figure 绘图容器 — 类似 matplotlib 的多绘图布局
  • 多坐标轴 — 寄生轴架构,支持任意多个坐标轴
  • 坐标轴交互 — 鼠标拖动、滚轮缩放
  • 2D/3D 一体化 — 内置 3D 绘图模块
  • C++11 优化 — 全面使用 overridenullptr、智能指针、范围 for 循环等现代 C++ 特性
  • 超大规模数据渲染优化 — 4 种曲线降采样算法 + SIMD 加速,百万级数据流畅渲染
  • 颜色循环系统 — 可自定义的颜色循环,自动为系列数据分配颜色
  • 箱线图QwtPlotBoxChart 支持统计分布可视化
  • Flat 风格控件 — 滑块、旋钮、刻度盘等控件支持扁平化样式

快速集成

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/figure

  • 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/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
    数据拾取器

版权信息

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.