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实心标准饼状图
mengzhi啊2024-08-24 12:22
相关推荐