diff --git a/src/qchartwidget.cpp b/src/qchartwidget.cpp index 6541717..528eb00 100644 --- a/src/qchartwidget.cpp +++ b/src/qchartwidget.cpp @@ -7,16 +7,15 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE QChartWidget::QChartWidget(QWidget *parent) : -QWidget(parent) +QGraphicsView(parent) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_scene = new QGraphicsScene(); - m_view = new QGraphicsView(parent); - m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_view->setScene(m_scene); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setScene(m_scene); m_chart = new QChart(); m_scene->addItem(m_chart); - m_view->show(); + show(); } QChartWidget::~QChartWidget() @@ -25,7 +24,6 @@ QChartWidget::~QChartWidget() void QChartWidget::resizeEvent(QResizeEvent *event) { - m_view->resize(size().width(),size().height()); m_scene->setSceneRect(0,0,size().width(),size().height()); m_chart->setSize(size()); QWidget::resizeEvent(event); diff --git a/src/qchartwidget.h b/src/qchartwidget.h index 85984b4..92f6b6d 100644 --- a/src/qchartwidget.h +++ b/src/qchartwidget.h @@ -3,9 +3,8 @@ #include "qchartglobal.h" #include "qchart.h" -#include +#include -class QGraphicsView; class QGraphicsScene; QTCOMMERCIALCHART_BEGIN_NAMESPACE @@ -13,7 +12,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE class QChartSeries; class QChartWidgetPrivate; -class QTCOMMERCIALCHART_EXPORT QChartWidget : public QWidget +class QTCOMMERCIALCHART_EXPORT QChartWidget : public QGraphicsView { Q_OBJECT public: @@ -30,7 +29,6 @@ public: private: Q_DISABLE_COPY(QChartWidget) - QGraphicsView *m_view; QGraphicsScene *m_scene; QChart* m_chart;