80 lines
2.1 KiB
C++
80 lines
2.1 KiB
C++
|
|
#include "SystemSelfcheck.h"
|
||
|
|
#include "ui_SystemSelfcheck.h"
|
||
|
|
|
||
|
|
CSystemSelfcheck::CSystemSelfcheck(QWidget *parent) :
|
||
|
|
QWidget(parent),
|
||
|
|
ui(new Ui::CSystemSelfcheck)
|
||
|
|
{
|
||
|
|
ui->setupUi(this);
|
||
|
|
ui->widget_6->setProperty("flag", "Title");
|
||
|
|
ui->widget->setProperty("flag", "normal");
|
||
|
|
|
||
|
|
m_centerLabel = new QLabel(ui->chartView);
|
||
|
|
m_centerLabel->setStyleSheet(QString("background:transparent;font-family:\"微软雅黑\";"
|
||
|
|
"font-size:20px; color:#409CE1; font-weight:900;"));
|
||
|
|
m_centerLabel->hide();
|
||
|
|
|
||
|
|
initPieChart();
|
||
|
|
bulidPieChart(75);
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
CSystemSelfcheck::~CSystemSelfcheck()
|
||
|
|
{
|
||
|
|
delete ui;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void CSystemSelfcheck::resizeEvent(QResizeEvent *event)
|
||
|
|
{
|
||
|
|
Q_UNUSED(event)
|
||
|
|
|
||
|
|
m_centerLabel->move((ui->chartView->width()-m_centerLabel->width())/2,
|
||
|
|
(ui->chartView->height()-m_centerLabel->height())/2);
|
||
|
|
|
||
|
|
// m_bottomLabel->move((ui->chartView->width()-m_bottomLabel->width())/2,
|
||
|
|
// ui->chartView->height() - m_bottomLabel->height() - 15);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void CSystemSelfcheck::initPieChart()
|
||
|
|
{
|
||
|
|
QChart *chart = new QChart();
|
||
|
|
|
||
|
|
chart->setAnimationOptions(QChart::SeriesAnimations);
|
||
|
|
|
||
|
|
m_ChartView = ui->chartView;
|
||
|
|
ui->chartView->setChart(chart);
|
||
|
|
ui->chartView->setRenderHint(QPainter::Antialiasing);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void CSystemSelfcheck::bulidPieChart(int percent)
|
||
|
|
{
|
||
|
|
m_centerLabel->setText(QString(" %1%\n%2").arg(percent).arg("自检进度"));
|
||
|
|
QChart *chart = ui->chartView->chart();
|
||
|
|
chart->removeAllSeries();
|
||
|
|
|
||
|
|
ui->chartView->setRenderHint(QPainter::NonCosmeticDefaultPen);
|
||
|
|
QPieSeries *series = new QPieSeries();//创建饼图序列
|
||
|
|
series->setHoleSize(0.66);//饼图中间空心的大小
|
||
|
|
series->setPieSize(0.8);//饼图的大小
|
||
|
|
|
||
|
|
QPieSlice *slice0 = new QPieSlice();
|
||
|
|
slice0->setValue(percent);
|
||
|
|
slice0->setColor(QColor(64, 156, 225));
|
||
|
|
|
||
|
|
QPieSlice *slice1 = new QPieSlice();
|
||
|
|
slice1->setValue(100 - percent);
|
||
|
|
slice1->setColor(QColor(231, 238, 251));
|
||
|
|
|
||
|
|
series->append(slice0);
|
||
|
|
series->append(slice1);
|
||
|
|
|
||
|
|
chart->addSeries(series);
|
||
|
|
chart->legend()->setVisible(false);
|
||
|
|
|
||
|
|
m_centerLabel->show();
|
||
|
|
resizeEvent(NULL);
|
||
|
|
}
|