qt实心标准饼状图

复制代码
   QString strOK = "OK:90%";
    float numOK = 0.9;
    QString strNG = "NG:10%";
    float numNG = 0.1;
    printA( strOK, numOK, strNG, numNG);

void MainWindow::printA(QString strOK,float numOK,QString strNG,float numNG)
{
    QPieSlice *slice_1 = new QPieSlice(this);
    slice_1->setLabel(strOK);
    slice_1->setValue(numOK);
    slice_1->setLabelVisible(true);
    slice_1->setColor(QColor(0,255,0,255));  //设置颜色

    QPieSlice *slice_2 = new QPieSlice( this);
    slice_2->setLabel(strNG);
    slice_2->setValue(numNG);
    slice_2->setLabelVisible(true);
    slice_2->setColor(QColor(255,0,0,255));  //设置颜色

    // 将两个饼状分区加入series
    QPieSeries *series = new QPieSeries(this);
    series->append(slice_1);
    series->append(slice_2);

    // 创建Chart画布
    QChart *chart = new QChart();
    chart->addSeries(series);
  //  chart->setAnimationOptions(QChart::AllAnimations); // 设置显示时的动画效果-拉跨
    chart->setTitle(u8"生产质量状况");

    // 将参数设置到画布
    ui->graphicsView->setChart(chart);
    ui->graphicsView->setRenderHint(QPainter::Antialiasing);
    ui->graphicsView->chart()->setTheme(QChart::ChartTheme(0));
}
相关推荐
Quz4 天前
QML Hello World 入门示例
qt
xcyxiner7 天前
DicomViewer (dcmtk读取dcm文件)5
qt
xcyxiner8 天前
DicomViewer (后台线程处理文件)4
qt
xcyxiner8 天前
DicomViewer (添加模型类)3
qt
xcyxiner9 天前
DicomViewer (目录调整) 2
qt
xcyxiner9 天前
dcmtk vtk vtk-dicom(gdcm) 编译(debug) v2
qt
桥田智能11 天前
桥田智能 QT-650S:面向白车身焊装的 800kg 重载快换解决方案
开发语言·qt·系统架构
森G11 天前
75、服务器源码解析---------云视频服务项目
linux·服务器·网络·c++·qt
森G11 天前
77、线程池原理和实现------服务器源码解析----云视频服务项目
服务器·c++·qt
森G11 天前
71、打包发布---------打包发布
c++·qt