qcustomplot学习笔记1-开发环境搭建

来源:互联网 发布:微信小程序 数据库 编辑:程序博客网 时间:2024/06/05 04:21

现在qt绘图大家用的比较多的还算是qwt和qcustomplot。qt官方出的qcharts,qt5.4以后才能用,嵌入式系统可能还是不怎么考虑。

以前用过qwt进行绘制,环境搭建的时间稍微麻烦一些。官方提供的库的使用教程不是源码形式使用,debug不太方便。qcustomplot加一个头文件和一个源文件就行,也可以debug方便很多。

1.代码下载

官方网站可以很方便下载:http://www.qcustomplot.com/

http://www.qcustomplot.com/index.php/download

2.把解压出来的源文件qcustomplot.cpp和qcustomplot.h拷贝到源文件目录,并把这两个文件加入.pro文件中。

添加后的.pro文件

#-------------------------------------------------## Project created by QtCreator 2017-06-21T16:36:53##-------------------------------------------------QT       += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupportTARGET = qcp_1TEMPLATE = app# The following define makes your compiler emit warnings if you use# any feature of Qt which as been marked as deprecated (the exact warnings# depend on your compiler). Please consult the documentation of the# deprecated API in order to know how to port your code away from it.DEFINES += QT_DEPRECATED_WARNINGS# You can also make your code fail to compile if you use deprecated APIs.# In order to do so, uncomment the following line.# You can also select to disable deprecated APIs only up to a certain version of Qt.#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0SOURCES += main.cpp\        mainwindow.cpp\        qcustomplot.cppHEADERS  += mainwindow.h\        qcustomplot.hFORMS    += mainwindow.ui
3.在ui中添加一个QWidget,然后提升为QCustomPlot类

4.然后就可以正常使用QCustomPlot进行曲线绘制了。

阅读全文
0 0
原创粉丝点击