zoukankan      html  css  js  c++  java
  • QLineSeries QChartView 生成折线

    效果图

        // 创建折线上点的序列
        QLineSeries *splineSeries = new QLineSeries();
        //QSplineSeries *splineSeries = new QSplineSeries();
        splineSeries->setName("spline");
    
    
        splineSeries->append(0, 6);
        splineSeries->append(2, 4);
        splineSeries->append(3, 8);
        splineSeries->append(7, 4);
        splineSeries->append(10, 5);
        *splineSeries << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2);
    
    
        // 标记点
        QScatterSeries *scatterSeries = new QScatterSeries();
        scatterSeries->setPointLabelsFormat("@yPoint");
        scatterSeries->setPointLabelsVisible();
        scatterSeries->setMarkerSize(8);
        scatterSeries->append(0, 6);
        scatterSeries->append(2, 4);
        scatterSeries->append(3, 8);
        scatterSeries->append(7, 4);
        scatterSeries->append(10, 5);
        *scatterSeries << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2);
    
    
    //    //区域填充
    //    QAreaSeries *series = new QAreaSeries(splineSeries);
    //    series->setName("Batman");
    //    QPen pen(0x059605);
    //    pen.setWidth(3);
    //    series->setPen(pen);
    
    
        // 使用点的序列创建图标
        QChart *chart = new QChart();
        chart->legend()->hide();
        chart->addSeries(splineSeries);
        chart->addSeries(scatterSeries);
        //chart->addSeries(series);
        chart->createDefaultAxes();
        chart->axisY()->setRange(0, 10);
    
    
    //    //X轴下标
    //    QStringList categories;
    //    categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" ;
    //    QBarCategoryAxis *axisX = new QBarCategoryAxis();
    //    axisX->append(categories);
    //    chart->setAxisX(axisX, scatterSeries);
    
    
    
    
    
    
        QChartView *chartView = new QChartView(chart);
        chartView->setRenderHint(QPainter::Antialiasing);
    
    
    
    
        MainWindow w;
        w.setCentralWidget(chartView);
        w.show();
  • 相关阅读:
    SQLSERVER查询所有数据库名,表名,和字段名
    SQL通过拆分某字段中的内容来实现与对应表连接查询
    [SPOJ]CIRU 圆并
    有关反演和GCD
    docker部署 jenkins
    mongoDB学习记录(二)
    docker动态修改容器限制
    ORACLE数据库误操作DELETE并且提交数据库之后如何恢复被删除的数据
    用8个命令调试Kubernetes集群
    db2服务器linux的cache过高原因
  • 原文地址:https://www.cnblogs.com/zhangxuan/p/10149927.html
Copyright © 2011-2022 走看看