- Qt 5.12.1
- MinGW 7.3.0 (Windows10)
#include "custompiechart.h" // 导入头文件
CustomPieChart * pieChart = new CustomPieChart(this);
// CustomPieChart(parent)
CustomPieChart * pieChart_1 = new CustomPieChart("逆变器31(台)", "小型", 18, Qt::blue, this);
// CustomPieChart(titleName, tag, data, color, parent)
QList<int> dataList = { 31, 25, 10 };
QStringList tagList = { "正常", "离线", "异常" };
QList<QColor> colorList = {QColor(57, 207, 206), QColor(232, 184, 232), Qt::yellow};
CustomPieChart * pieChart_2 = new CustomPieChart("数据采集器1(台)", tagList, dataList, colorList, this);
// CustomPieChart(titleName, tagList, dataList, colorList, parent)
pieChart->addSlice(tag, data, color);
pieChart->setSeries(tagList, dataList, colorList);
QFont tempFont;
tempFont.setPointSize(9);
tempFont.setFamily("Microsoft YaHei");
tempFont.setWeight(80);
pieChart->setGlobalFont(tempFont); // QFont tempFont
pieChart->setTitleFont(tempFont); // QFont tempFont
pieChart->setTagFont(tempFont); // QFont tempFont
pieChart->setLegendFont(tempFont); // QFont tempFont
pieChart->setSumFont(tempFont); // QFont tempFont
pieChart->setSumTextFont(tempFont); // QFont tempFont
pieChart->setRingSize(ringSize); // double ringSize