• QSplineSeries QChartView绘制曲线


    参考资料:

    https://www.qtdebug.com/qtbook-paint-smooth-curve-qchart/

    https://blog.csdn.net/liang19890820/article/details/54618026

    https://blog.csdn.net/lmhuanying1012/article/details/78455037

    https://blog.csdn.net/a844651990/article/details/82706466

    https://blog.csdn.net/u010304326/article/details/79185968

        // 创建平滑曲线上点的序列
        //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->setTitle("平滑曲线");
        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();
  • 相关阅读:
    i3wm 入门
    install kali on my x200
    Linux下pn532板子测试学校水卡
    Linux下常用工具
    未能加载文件或程序集"Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad
    SqlServer 日期函数
    asp.net 网站部署出错-未在本地计算机上注册“Microsoft.Jet.OLEDB.4.0”提供程序
    win7中未加载类型“System.ServiceModel.Activation.HttpModule”
    ASP.NET开发工具用到的密匙与注意事项
    TCP/TP 三次握手
  • 原文地址:https://www.cnblogs.com/zhangxuan/p/10149970.html
Copyright © 2020-2023  润新知