1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #ifndef CUSTOMPIECHART_H
- #define CUSTOMPIECHART_H
- #include <QPainter>
- #include <QPaintEvent>
- #include <QVBoxLayout>
- #include <QWidget>
- #include <QLabel>
- #include <QtMath>
- class CustomPieChart : public QWidget
- {
- Q_OBJECT
- public:
- explicit CustomPieChart(QWidget *parent = nullptr);
- explicit CustomPieChart(const QString &title, const QString &tag, const int &data, const QColor &color,
- QWidget *parent = nullptr);
- explicit CustomPieChart(const QString &title, QStringList tagList, QList<int> dataList, QList<QColor> colorList,
- QWidget *parent = nullptr);
- ~CustomPieChart();
- void addSlice(const QString &tag, const int &data, const QColor &color);
- void setSeries(QStringList tagList, QList<int> value, QList<QColor> colorList);
- void setTitleFont(const QFont &font);
- void setTagFont(const QFont &font);
- void setLegendFont(const QFont &font);
- void setSumFont(const QFont &font);
- void setSumTextFont(const QFont &font);
- void setGlobalFont(const QFont &font);
- void setRingSize(const double &ringSize);
- private:
- int total;
- double sum;
- QFont globalFont;
- QFont titleFont;
- QFont tagFont;
- QFont legendFont;
- QFont sumFont;
- QFont sumTextFont;
- bool isSetTitleFont;
- bool isSetTagFont;
- bool isSetLegendFont;
- bool isSetSumFont;
- bool isSetSumTextFont;
- double fontSize;
- double ringSize;
- QWidget *titleWidget;
- QWidget *pieChartWidget;
- QString title;
- QStringList tagList;
- QList<int> dataList;
- QList<QColor> colorList;
- bool eventFilter(QObject *widget, QEvent *event);
- void drawPieChart();
- void initPieChartWidget();
- };
- #endif
|