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

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_24815615/article/details/73551049

现在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 gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport

TARGET = qcp_1
TEMPLATE = 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.0


SOURCES += main.cpp\
        mainwindow.cpp\
        qcustomplot.cpp

HEADERS  += mainwindow.h\
        qcustomplot.h

FORMS    += mainwindow.ui
3.在ui中添加一个QWidget,然后提升为QCustomPlot类

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

猜你喜欢

转载自blog.csdn.net/qq_24815615/article/details/73551049