#ifndef CLASSCHART_H#define CLASSCHART_H#include <QWidget>#include <QtCharts>#include <QGraphicsTextItem>namespace Ui {class ClassChart;}class ClassChart : public QChart{ Q_OBJECTpublic: explicit ClassChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); ~ClassChart();protected: void resizeEvent(QResizeEvent *event);private: QGraphicsSimpleTextItem *chartCoordX, *chartCoordY;};#endif // CLASSCHART_H
#include "classchart.h"ClassChart::ClassChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QChart(QChart::ChartTypeCartesian, parent, wFlags){ chartCoordX = new QGraphicsSimpleTextItem(this); chartCoordX->setText(tr("X: ")); chartCoordY = new QGraphicsSimpleTextItem(this); chartCoordY->setText(tr("Y: "));}ClassChart::~ClassChart(){}void ClassChart::resizeEvent(QResizeEvent *event){ chartCoordX->setPos(size().width()/2 - 50, size().height()); chartCoordX->setPos(size().width()/2 + 50, size().height());}
resizeEvent(QGraphicsSceneResizeEvent *event)