QCustomPlot 1.0.1学习(1)-下载和使用QCustomPlot

本文介绍了如何在Qt环境中使用QCustomPlot库进行数据可视化。首先,通过官方链接下载QCustomPlot,接着将其源码添加到Qt项目中。在UIDesigner中,可以通过控件提升法或直接使用法将QCustomPlot添加到界面。通过实例展示了两种方法的实现步骤,并给出了运行效果。QCustomPlot支持实时数据展示和高质量图表导出,适用于各种数据可视化需求。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、QCustomPlot介绍

QCustomPlot is a Qt C++ widget for plotting and data visualization. It has no further dependencies and is well documented. This plotting library focuses on making good looking, publication quality 2D plots, graphs and charts, as well as offering high performance for realtime visualization applications. Have a look at the Setting Up and the Basic Plotting tutorials to get started.

QCustomPlot can export to various formats such as vectorized PDF files and rasterized images like PNG, JPG and BMP. QCustomPlot is the solution for displaying of realtime data inside the application as well as producing high quality plots for other media.

2、QCustomPlot的下载

QCustomPlot官网链接:https://www.qcustomplot.com/index.php/introduction

下载链接:https://www.qcustomplot.com/index.php/download

我这里以1.0.1版本进行学习,所以点击上图红框部分,即可下载完全安装包,包括源码,文档,帮助文件等。

 3、QCustomPlot的使用

3.1、新建一个Qt界面程序

 创建好后,项目结构如下:

3.2、将QCustomPlot源码文件添加到项目里 

将下载好的压缩文件QCustomPlot.tar.gz拷贝到项目目录里,然后进行解压。

我这里解压到QCustomPlot文件夹下,这样文件不会很乱。

 

QCustomPlot文件夹下包含如下文件:

 

 其中:

  • qcustomplot.h和qcustomplot.cpp是源码文件
  • documentation是文档目录
  • examples是案例目录

将qcustomplot.h和qcustomplot.cpp添加到项目里,添加后项目结构如下:

 3.2.1、控件提升法

双击mainwindow.ui界面文件,在UI Designer中,可以拖动一个Widget控件到ui设计器上,对这个窗体点击右键,选择提升为:

在提升的窗口部件窗口里,输入如下信息:

然后,依次点击添加、提升按钮。

提升后,窗体对象列表如下:

 这里将centralWidget使用水平布局,widget改名为customPlot。修改后的窗体对象列表如下:

运行:

 

 

 

3.2.2、直接使用法

 直接使用法指的是在使用QCustomPlot文件的地方,直接包含头文件,然后程序里显示的创建QCustomPlot控件。

代码:

    QCustomPlot *customPlot=new QCustomPlot;

    QHBoxLayout *mainLayout=new QHBoxLayout;
    mainLayout->addWidget(customPlot);

    ui->centralWidget->setLayout(mainLayout);

    setWindowTitle("直接使用法");

运行:

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

沉淀期待未来9527

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值