##// END OF EJS Templates
Refactoring: QChartWidget is now a QGraphicsView
Tero Ahola -
r55:6d83ac09aba2
parent child
Show More
@@ -7,16 +7,15
7 7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 8
9 9 QChartWidget::QChartWidget(QWidget *parent) :
10 QWidget(parent)
10 QGraphicsView(parent)
11 11 {
12 12 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
13 13 m_scene = new QGraphicsScene();
14 m_view = new QGraphicsView(parent);
15 m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
16 m_view->setScene(m_scene);
14 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
15 setScene(m_scene);
17 16 m_chart = new QChart();
18 17 m_scene->addItem(m_chart);
19 m_view->show();
18 show();
20 19 }
21 20
22 21 QChartWidget::~QChartWidget()
@@ -25,7 +24,6 QChartWidget::~QChartWidget()
25 24
26 25 void QChartWidget::resizeEvent(QResizeEvent *event)
27 26 {
28 m_view->resize(size().width(),size().height());
29 27 m_scene->setSceneRect(0,0,size().width(),size().height());
30 28 m_chart->setSize(size());
31 29 QWidget::resizeEvent(event);
@@ -3,9 +3,8
3 3
4 4 #include "qchartglobal.h"
5 5 #include "qchart.h"
6 #include <QWidget>
6 #include <QGraphicsView>
7 7
8 class QGraphicsView;
9 8 class QGraphicsScene;
10 9
11 10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -13,7 +12,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
13 12 class QChartSeries;
14 13 class QChartWidgetPrivate;
15 14
16 class QTCOMMERCIALCHART_EXPORT QChartWidget : public QWidget
15 class QTCOMMERCIALCHART_EXPORT QChartWidget : public QGraphicsView
17 16 {
18 17 Q_OBJECT
19 18 public:
@@ -30,7 +29,6 public:
30 29
31 30 private:
32 31 Q_DISABLE_COPY(QChartWidget)
33 QGraphicsView *m_view;
34 32 QGraphicsScene *m_scene;
35 33 QChart* m_chart;
36 34
General Comments 0
You need to be logged in to leave comments. Login now