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));
}
相关推荐
QT 小鲜肉1 小时前
【个人成长笔记】Qt 中 SkipEmptyParts 编译错误解决方案及版本兼容性指南
数据库·c++·笔记·qt·学习·学习方法
OneSea1 小时前
Debian编译Qt5
linux·qt
看到我,请让我去学习1 小时前
Qt 控件 QSS 样式大全(通用属性篇)
开发语言·c++·qt
曦樂~7 小时前
【Qt】信号与槽(Signal and Slot)- 简易计算器
开发语言·数据库·qt
十五年专注C++开发7 小时前
QDarkStyleSheet: 一个Qt应用的暗色主题解决方案
开发语言·c++·qt·qss
Algebraaaaa1 天前
什么是前端、后端与全栈开发,Qt属于什么?
开发语言·前端·qt
大美B端工场-B端系统美颜师1 天前
工控软件开发选择难?Electron、Qt、WPF 对比
qt·electron·wpf
QT 小鲜肉1 天前
【个人成长笔记】Qt Creator快捷键终极指南:从入门到精通
开发语言·c++·笔记·qt·学习·学习方法
feiyangqingyun1 天前
Qt项目作品在苹果macos上编译运行效果/视频监控系统/物联网平台等
开发语言·qt·macos
fsnine1 天前
Python图形化界面——pyqt5教程
开发语言·python·qt