Qt学习笔记NO2. QCustomPlot 学习使用笔记

一、学习参考资料

官网 : Qt Plotting Widget QCustomPlot - Introduction

二、QCustomPlot相关介绍

2.1 配置QCustomPlot

  • 首先,下载QCustomPlot库,将qcustomplot.h and qcustomplot.cpp 添加入工程
  • 然后,在.pro文件添加:

  • 接着可以选择将QWidget放置UI界面,提升为qcustomplot

  • 也可以直接在工程添加以下代码
//直接在构造函数,初始化QCustomPlot
mPlot = new QCustomPlot(this);
setCentralWidget(mPlot);

2.2 使用QCustomPlot绘制基础图像

效果:

 代码:

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

===未完,后续应用再补充

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值