关于QCustomPlot的绘图
来源:互联网 发布:wcf 数据库 编辑:程序博客网 时间:2024/06/05 08:45
该类可完成2D图形的绘制,下载地址为:http://www.qcustomplot.com/index.php/download,推荐下载最上面一个的首个文件,里面有类,还有代码可以参考。
这个类我上传至http://download.csdn.net/detail/zhulichen/9783916,大家可以下载下来使用
自己先新建一个工程,并将qcustomplot.h与qcustomplot.cpp拷贝到目录工程下,然后将该两个文件添加至工程中。同时需要在.pro文件 QT +=widgets 后面添加printsupport
在.ui界面中拖入一个widget区域,选中widget区域点击右键,选择“提升为”按钮,将提成的类名称。
现在运行下,将出现了简单的坐标系,该坐标系默认的坐标为(0,5)(0,5)
很多文章中显示的都是画线,我在这里写的程序是显示点,每次可以输入一个点,然后显示在坐标系。
在.h头文件中添加函数:
public:
void updateWidgetShow(QCustomPlot *customPlot);
QPointF inputPoint(float x,float y);
在.cpp文件中添加
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "qcustomplot.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
updateWidgetShow(ui->widget);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::updateWidgetShow(QCustomPlot *customPlot)
{
customPlot->clearGraphs();
customPlot->setBackground(QPixmap("./background.jpg"));
//customPlot->axisRect()->setBackground(QPixmap("./background.jpg"));
customPlot->addGraph();
customPlot->graph()->setLineStyle(QCPGraph::lsNone);
customPlot->graph()->setScatterStyle(QCPScatterStyle(QPixmap("./sun.png")));
QPointF label=inputPoint(5.9,2.3);
QVector<double> xx(1),yy(1);
xx[0]=label.x();
yy[0]=label.y();
customPlot->graph()->addData(xx,yy);
customPlot->replot();
customPlot->xAxis->setRange(0,10);
customPlot->yAxis->setRange(0,10);
}
QPointF MainWindow::inputPoint(float x, float y)
{
QPointF point;
point.setX(x);
point.setY(y);
return point;
}
运行一下,结果如下图所示:源码我已上传到:http://download.csdn.net/detail/zhulichen/9783906
0 0
- 关于QCustomPlot的绘图
- 关于Qt绘图控件qCustomPlot
- QCustomPlot绘图控件的使用
- QCustomPlot之绘图的基础
- QCustomPlot之绘图的基础
- 使用QCustomPlot绘图的基础
- QCustomPlot绘图
- QT绘图工具QCustomPlot
- Qt绘图控件QCustomPlot安装
- QCustomPlot绘图(一):使用入门
- 【分享】分享一个非常漂亮且好用的绘图控件QCustomPlot - qwt的完美替代品
- Qt绘图插件QCustomPlot配置、使用
- QT绘图之第三方库QCUSTOMPLOT
- Qt + Qcustomplot绘图插件安装和配置
- QCustomPlot的基本使用
- QCustomPlot的安装使用
- QCustomPlot的简单使用
- QCustomPlot的replot效率
- c++ primer 概念整理第五章 语句
- 伪类选择器
- myeclipse显示代码行数
- 2017.03.16_iterator、EnhancedFor及Set
- JSP声明语句/脚本段/表达式
- 关于QCustomPlot的绘图
- 【变量过滤】防止代码注入
- java:求一个字符串中子字符串的个数,简便算法
- Day008:merge two sorted lists
- android tree树状列表+checkbox
- 迷茫<第一篇:初到北京>
- [转]Facebook 开源的快速文本分类器 FastText
- iOS 刷新一个行
- 2016级数据结构第一次上机解题报告