首页 > 系统相关 >LINUX-chart图表简单操作

LINUX-chart图表简单操作

时间:2023-01-26 14:33:50浏览次数:56  
标签:Qt axisX axisY chart 图表 pen LINUX series1

添加模块

 

 

 添加头文件

 

 

需要在窗体上放置 QChartView控件,工具箱没找到,需要在别的项目复制过来一个这个控件。

代码

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

   // QChartView *chartView=new QChartView(this); //创建 ChartView

    QChart *chart = new QChart(); //创建 Chart
    chart->setTitle("温湿度数据曲线");

  // chartView->setChart(chart); //Chart添加到ChartView
   // this->setCentralWidget(chartView);
    ui->chartViewBar->setChart(chart);

//创建曲线序列
    QLineSeries *series0 = new QLineSeries();
    QLineSeries *series1 = new QLineSeries();
    series0->setName("温度曲线");
    series1->setName("湿度曲线");
    chart->addSeries(series0); //序列添加到图表
    chart->addSeries(series1);

//    QPen    pen;
//    pen.setStyle(Qt::DotLine);//Qt::SolidLine, Qt::DashLine, Qt::DotLine, Qt::DashDotLine
//    pen.setWidth(2);
//    pen.setColor(Qt::red);
//    series0->setPen(pen);

//    pen.setStyle(Qt::SolidLine);//Qt::SolidLine, Qt::DashLine, Qt::DotLine, Qt::DashDotLine
//    pen.setColor(Qt::blue);
//    series1->setPen(pen);

//序列添加数值
//    qreal   t=0,y1,y2,intv=0.1;
//    int cnt=100;
//    for(int i=0;i<cnt;i++)
//    {
//        y1=qSin(t);//+qrand();
//        series0->append(t,y1);

//        y2=qSin(t+20);
//        series1->append(t,y2);

//        t+=intv;
//    }

       series0->append(2.5,1);
       series0->append(5,1.3);

       series1->append(2,1.2);
       series1->append(5,1.5);


//    chart->createDefaultAxes();
//    chart->axisX()->setTitleText("time(secs)");
//    chart->axisY()->setTitleText("value");

//创建坐标轴
    QValueAxis *axisX = new QValueAxis; //X 轴
    axisX->setRange(0, 24); //设置坐标轴范围
//    axisX->setLabelFormat("%.1f"); //标签格式
//    axisX->setTickCount(11); //主分隔个数
//    axisX->setMinorTickCount(4);
    axisX->setTitleText("time(secs)"); //标题
//    axisX->setGridLineVisible(false);

    QValueAxis *axisY = new QValueAxis; //Y 轴
    axisY->setRange(0, 60);
    axisY->setTitleText("value");
//    axisY->setTickCount(5);
//    axisY->setMinorTickCount(4);
//    axisY->setLabelFormat("%.2f"); //标签格式
//    axisY->setGridLineVisible(false);

    chart->setAxisX(axisX, series0); //为序列设置坐标轴
    chart->setAxisY(axisY, series0); //

    chart->setAxisX(axisX, series1); //为序列设置坐标轴
    chart->setAxisY(axisY, series1); //
}

 

标签:Qt,axisX,axisY,chart,图表,pen,LINUX,series1
From: https://www.cnblogs.com/yzdz2/p/17067815.html

相关文章

  • Linux安装nginx
    1.下载nginxwgethttp://nginx.org/download/nginx-1.13.7.tar.gz2.安装依赖yuminstallgcc-c++yuminstall-ypcrepcre-develyuminstall-yzlibzlib-deve......
  • 新版TinyCore Linux系统安装
      1.设置软件仓库源echo"https://mirrors.163.com/tinycorelinux">/opt/tcemirror 2.安装启动加载器及其依赖tce-load-wi grub2-multi.tcz  liblvm2.tcz ......
  • 常用 Linux 命令总结
    1.基本命令uname-m 显示机器的处理器架构uname-r显示正在使用的内核版本dmidecode-q显示硬件系统部件(SMBIOS/DMI)hdparm-i/dev/hda罗列一个磁盘的架构特性h......
  • Compile Sqlite3 Executable, Static Library, and Shared Library on Linux
    DownloadSqlite3sourcecode,anddecompressittosomewhere.Enterthedecompressedfolder,typethefollowingcommandtogeneratedifferenttargetswithall......
  • linux rhel虚拟机中如何给磁盘动态扩容(硬盘直接扩展)
     001、查看磁盘、容量[root@PC1~]#find/dev/-name"sd*"##查看磁盘数目,分区,一共一块硬盘sda/dev/sda2/dev/sda1/dev/sda[root@PC1~]#lsblk......
  • echarts基本配置
    <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><metahttp-equiv=......
  • linux rhel虚拟中如何给磁盘动态扩容
     001、当前的硬盘个数及挂载情况[root@PC1~]#find/dev/-name"sd*"##一共一块硬盘sda,两个分区sda1和sda2/dev/sda2/dev/sda1/dev/sda[root@......
  • 61Linux命令退格键变成^H的解决办法
    执行py脚本,空格变成^HLinux命令退格键变成^H的解决办法1.按住ctrl键再去按退格键(backspace),就ok了;2.把sttyerase^H添加到.bash_profile中。操作如下:......
  • 60Linux里虚拟环境
    linuxcentos7python虚拟环境默认第三方库安装位置/usr/local/lib/python3.6/site-packages我的项目在/root/pythonProject/projects步骤1.pip3installvirtuale......
  • Linux运维之解决服务器挖矿木马问题
    目录1挖矿木马1.1定义1.2挖矿特征1.3解决挖矿木马1.3.1阻断异常网络通信(非必需)1.3.2清除定时任务1.3.3清除启动项1.3.4清除SSH公钥1.3.5清除木马进程1.4其他常见......