QCustomPlot 使用手册(一)
介绍
QCustomPlot 是一个基于 Qt 的画图和数据可视化 C++控件。QCustomPlot 致力于提供美
观的界面,高质量的 2D 画图、图画和图表,同时为实时数据可视化应用提供良好的解决方
案。
类相关
继承
获取
下载地址:http://qcustomplot.com/index.php/download,QCustomPlot.tar.gz,目前更新到 1.3.1
版本。
官网:http://qcustomplot.com/index.php/introduction
论坛:http://qcustomplot.com/index.php/support/forum
1
使用
在你的应用中使用 QCustomPlot 有 2 种方法:
1、 将下载下 来的 qcustomplot.h 和 qcustomplot.cpp 加 入你的工程中。在你要使 用
qcustomplot 的文件中:
#include "qcustomplot.h"
然后像使用 QWidget 那样使用就行,因为 QCustomPlot 也是继承自 QWidget 的:
使用 Qt Designer 的话,在一个 QWidget 控件右键,提升为...,
QCustomplot *myqcp = new QCustomPlot;
然后在弹出的对话框中,在提升为类名那里输入 QCustomPlot,然后头文件那里会自动
填充为 qcustomplot.h。单击添加按钮将 QCustomPlot 加入提升类列表中,最后单击提
升就可以了。
注意:提升之后不会立即看到什么变化,但当你运行程序的时候,你就能看到控件具有
坐标和网格了。
2、 不用包含 qcustomplot.h 和 qcustomplot.cpp,只需引入 qcustomplot.so (GNU/Linux)
或 qcustomplot.dll(MSWindows) file。接下来说明如何编译 qcustomplot 库:
首先,从下载地址下载 QCustomPlot-sharedlib,然后拷贝 qcustomplot.h 和
qcustomplot.cpp 到与 qcustomplot-sharedlib 同级的目录下,然后在命令行模式进入
sharedlib-compilation 目录,运行 qmake;mingw32-make;稍等片刻就会产生俩个文件
夹 debug 和 release,里面分别有 qcustomplot 库的 debug 和 release 版本,windows
2
是.dll,linux 是.a(而官网说的是.so,有点出入?)然后怎么使用 qcustomplot 很简单,
我就不说了- -
注意:如果你使用的 Qt 版本在 5.0 以上,需要在.pro 文件中的 QT 变量加上
printsupport,
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
在 QtCreator 中使用帮助
在第二步下载的 documentation 文件夹下有个 qcustomplot.qch 文件,将它拷贝某个目录
下,例如 QtCreator 的安装目录下,然后在 QtCreator ,工具,选项,帮助,文档,添加,
选择 qcustomplot.qch 文件,确定,以后按 F1 就能跳转到 QCustomPlot 的帮助文档了.
效果
3
4
5
6
7
8