一、新建一个widget工程

二、将Qcustomplot文件复制到项目下

三、右键qt项目增加已存在的文件

四、在.pro中添加

QT += widgets printsupport

五、在.h中添加声明

private:
QCustomPlot *myPlot;

六、在.cpp中的构造函数中添加

    myPlot = new QCustomPlot(this);

    this->resize(,);
myPlot->resize(,); // generate some data:
QVector<double> x(), y(); // initialize with entries 0..100
for (int i=; i<; ++i)
{
x[i] = i/50.0 - ; // x goes from -1 to 1
y[i] = 0.75; // let's plot a quadratic function
}
// create graph and assign data to it:
myPlot->addGraph();
myPlot->graph()->setData(x, y);
// give the axes some labels:
myPlot->xAxis->setLabel("x");
myPlot->yAxis->setLabel("y");
// set axes ranges, so we see all data:
myPlot->xAxis->setRange(-, );
myPlot->yAxis->setRange(, );

就画出来一条直线了~

简单的使用Qt的QCustomplot画图的更多相关文章

  1. Qt之QCustomPlot(图形库)

    简述 QCustomPlot是一个基于Qt C++的图形库,用于绘制和数据可视化 - 制作漂亮的2D图 - 曲线图.趋势图.坐标图.柱状图等,并为实时可视化应用程序提供高性能服务.它没有进一步的依赖关 ...

  2. Qt之QCustomPlot绘图(一)配置和第一个例子

    最近一个用Qt开发的项目需要绘制坐标曲线,我在老师的指点下使用了QCustomPlot这个插件,使用方法简单,功能还算不错. 可是在网上找了很多资料和博文都只是将官方提供的例子演示一遍,没有系统全面的 ...

  3. Qt使用QCustomPlot开发

    一.入门 1.下载源文件http://www.qcustomplot.com/: 2.把.cpp和.h放在工程目录下,并将cpp和h加入工程: 3.在.pro中:QT += printsupport: ...

  4. Qt:QCustomPlot使用教程(三)——用户交互

    0.说明 本节翻译总结自:Qt Plotting Widget QCustomPlot - User Interactions 本节内容是使用QCustomPlot实现绘图和用户交互功能. 本文代码中 ...

  5. Qt:QCustomPlot使用教程(二)——基本绘图

    0.说明 本节翻译总结自:Qt Plotting Widget QCustomPlot - Basic Plotting 本节内容是使用QCustomPlot进行基本绘图. 本节教程都使用custom ...

  6. Qt:QCustomPlot使用教程(一)——安装与配置

    0.说明 本节翻译总结自:Qt Plotting Widget QCustomPlot - Setting Up 本节的内容是讲如何配置QCustomPlot,而QCustomPlot的具体用法可以看 ...

  7. QT之QCustomPlot(二)

    怎么设置X,Y轴位置 Manages a single axis inside a QCustomPlot. Usually doesn't need to be instantiated exter ...

  8. QT之QCustomPlot(一)

    QDetectPlot::QDetectPlot(QWidget *parent) : QCustomPlot(parent) { QVector<), y(); // initialize w ...

  9. 如何写一个简单的基于 Qt 框架的 HttpServer ?

    httpserver.h #ifndef HTTPSERVER_H #define HTTPSERVER_H #include <QObject> #include <QtCore& ...

随机推荐

  1. 网站运行一段时间后就无法访问,重启Tomcat才能恢复

    网站运行一段时间后就无法访问,重启Tomcat才能恢复出现这种情况,很可能是以下几种情况:1.超过数据库连接池上限2.并发数达到上限3.内存溢出具体还是需要通过打印的日志进行具体分析.解决方法1.如果 ...

  2. DCloud-Video:Html5 Video 实现方案

    ylbtech-DCloud-Video:Html5 Video 实现方案 1.返回顶部 1.1. http://ask.dcloud.net.cn/article/569 1.2. 一. Html5 ...

  3. MySQL-8.0填坑

    Client does not support authentication protocol 或 Authentication plugin 'caching_sha2_password' cann ...

  4. spring boot找不到或无法加载主类 io.renren.RenrenApplication

    spring boot找不到或无法加载主类 io.renren.RenrenApplication 出现问题: spring boot 项目以前一直是好好的,用mvn clean package 打包 ...

  5. 文件上传&&验证文件格式

    $(function(){ $(".layui-progress").hide(); $("[data-upload-file]").each(function ...

  6. sql server日志传送实践(基于server 2008 R2)

    SQL Server 2008 R2 主从数据库同步 相关参考:http://blog.itpub.net/30126024/viewspace-2639526/ sql server日志传送(基于s ...

  7. RegionServer Splitting Implementation:regionServer 分裂过程分析

    图片: RegionServer Split Process The RegionServer decides locally to split the region, and prepares th ...

  8. 【小程序】获取到的e.target与e.currentTarget区别

    [小程序]获取到的e.target与e.currentTarget区别:https://blog.csdn.net/qq_33744228/article/details/80310294 使用e.t ...

  9. 马士兵对话京东T6阿里P7(薪水):月薪5万,他为何要离职?

    马士兵大佬你知道吗? 你竟然不知道?你怎么可能不知道!你不知道是不可能的! 记得自己的第一行Java代码,你的Hello World是跟着谁学的吗?我的就是马士兵老师! 马士兵是唯一一个在当时讲课是让 ...

  10. CF1158C

    题意:有排列p, 令\(nxt_i\)为\(p_i\)右侧第一个大于\(p_i\)的数的位置,若不存在则\(nxt_i=n+1\) 现在整个p和nxt的一部分丢失了,请根据剩余的nxt,构造出一个符合 ...