##// END OF EJS Templates
Adds QChartView empty constructor to be able to promote qchartview in qtdesigner
Michal Klocek -
r1290:d3d22419eb01
parent child
Show More
@@ -50,22 +50,25
50 50 QTCOMMERCIALCHART_BEGIN_NAMESPACE
51 51
52 52 /*!
53 Constructs a chartView object with parent \a parent.
54 */
55
56 QChartView::QChartView(QWidget *parent) :
57 QGraphicsView(parent),
58 d_ptr(new QChartViewPrivate(this))
59 {
60
61 }
62
63 /*!
53 64 Constructs a chartView object with parent \a parent to display a \a chart.
54 65 */
66
55 67 QChartView::QChartView(QChart *chart,QWidget *parent) :
56 68 QGraphicsView(parent),
57 d_ptr(new QChartViewPrivate())
69 d_ptr(new QChartViewPrivate(this,chart))
58 70 {
59 Q_ASSERT(chart);
60 d_ptr->m_scene = new QGraphicsScene(this);
61 d_ptr->m_chart = chart;
62 setFrameShape(QFrame::NoFrame);
63 setBackgroundRole(QPalette::Window);
64 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
65 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
66 setScene(d_ptr->m_scene);
67 d_ptr->m_scene->addItem(chart);
68 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
71
69 72 }
70 73
71 74
@@ -198,14 +201,22 void QChartView::resizeEvent(QResizeEvent *event)
198 201
199 202 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
200 203
201 QChartViewPrivate::QChartViewPrivate():
202 m_scene(0),
203 m_chart(0),
204 QChartViewPrivate::QChartViewPrivate(QChartView *q,QChart* chart):
205 q_ptr(q),
206 m_scene(new QGraphicsScene(q)),
207 m_chart(chart),
204 208 m_presenter(0),
205 209 m_rubberBand(0),
206 210 m_rubberBandFlags(QChartView::NoRubberBand)
207 211 {
208
212 q_ptr->setFrameShape(QFrame::NoFrame);
213 q_ptr->setBackgroundRole(QPalette::Window);
214 q_ptr->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
215 q_ptr->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
216 q_ptr->setScene(m_scene);
217 q_ptr->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
218 if(!m_chart) m_chart = new QChart();
219 m_scene->addItem(m_chart);
209 220 }
210 221
211 222 QChartViewPrivate::~QChartViewPrivate()
@@ -48,6 +48,7 public:
48 48
49 49 Q_DECLARE_FLAGS(RubberBands, RubberBand)
50 50
51 explicit QChartView(QWidget *parent = 0);
51 52 explicit QChartView(QChart *chart,QWidget *parent = 0);
52 53 ~QChartView();
53 54
@@ -38,12 +38,18 class ChartPresenter;
38 38 QTCOMMERCIALCHART_BEGIN_NAMESPACE
39 39
40 40 class QChart;
41 class QChartView;
41 42
42 struct QChartViewPrivate {
43 class QChartViewPrivate {
43 44
44 QChartViewPrivate();
45 public:
46 QChartViewPrivate(QChartView *q,QChart *chart = 0);
45 47 ~QChartViewPrivate();
46 48
49 protected:
50 QChartView *q_ptr;
51
52 public:
47 53 QGraphicsScene *m_scene;
48 54 QChart *m_chart;
49 55 ChartPresenter *m_presenter;
@@ -86,6 +86,12 void tst_QChartView::qchartview()
86 86 QCOMPARE(m_view->rubberBand(), QChartView::NoRubberBand);
87 87 m_view->show();
88 88 QTest::qWaitForWindowShown(m_view);
89
90 delete(new QChartView());
91
92 QChartView view;
93 QVERIFY(view.chart());
94
89 95 }
90 96
91 97 void tst_QChartView::chart_data()
General Comments 0
You need to be logged in to leave comments. Login now