简单的图标绘制可以用QCustomPlot 就一个cpp和一个.h文件包含
其他的还有QT自身的QChart,不过要QT5.X以后的版本
下载QCustomPlot http://qcustomplot.com/index.php
最主要的类是 QCustomPlot,这是一个widget。所有的画图都是基于这个widget.
按照文章中基础的来写一个。
QCustomPlot customPlot() ;
customPlot.resize(600,400);
// generate some data:
QVector<double> x(101), y(101); // initialize with entries 0..100
for (int i=50; i<80; ++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();
customPlot.show();
实现了y=x^2的画图
本文介绍如何使用QCustomPlot库进行简单的图标绘制。通过一个示例程序展示了如何创建一个QCustomPlot widget,并绘制y=x^2的曲线图。文中还提供了设置坐标轴范围和标签的方法。
2万+

被折叠的 条评论
为什么被折叠?



