##// END OF EJS Templates
Changes scrollbar policy in qchartwidget
Michal Klocek -
r46:95744bf471a1
parent child
Show More
@@ -1,75 +1,77
1 1 #include "qchartwidget.h"
2 2 #include "qchartseries.h"
3 3 #include <QGraphicsView>
4 4 #include <QGraphicsScene>
5 5 #include <QResizeEvent>
6 6
7 7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 8
9 9 class QChartWidgetPrivate
10 10 {
11 11 public:
12 12 QChartWidgetPrivate(QChartWidget *parent) :
13 13 m_view(0),
14 14 m_scene(0),
15 15 m_chart(0)
16 16 {
17 17 m_scene = new QGraphicsScene();
18 18 m_view = new QGraphicsView(parent);
19 m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
20 m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
19 21 m_view->setScene(m_scene);
20 22 m_chart = new QChart();
21 23 m_scene->addItem(m_chart);
22 24 m_view->show();
23 25 }
24 26
25 27 ~QChartWidgetPrivate() {
26 28 }
27 29
28 30 QGraphicsView *m_view;
29 31 QGraphicsScene *m_scene;
30 32 QChart* m_chart;
31 33 };
32 34
33 35 ///////////////////////////////////////////////////////////////////////////////////////////////////
34 36
35 37 QChartWidget::QChartWidget(QWidget *parent) :
36 38 QWidget(parent),
37 39 d_ptr(new QChartWidgetPrivate(this))
38 40 {
39 41 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
40 42 }
41 43
42 44 QChartWidget::~QChartWidget()
43 45 {
44 46 delete d_ptr;
45 47 }
46 48
47 49 void QChartWidget::resizeEvent(QResizeEvent *event)
48 50 {
49 51 Q_D(QChartWidget);
50 52 d->m_view->resize(size().width(),size().height());
51 53 d->m_scene->setSceneRect(0,0,size().width(),size().height());
52 54 d->m_chart->setSize(size());
53 55 QWidget::resizeEvent(event);
54 56 }
55 57
56 58 QSize QChartWidget::sizeHint() const
57 59 {
58 60 // TODO: calculate size hint based on contents?
59 61 return QSize(100, 100);
60 62 }
61 63
62 64 void QChartWidget::addSeries(QChartSeries* series)
63 65 {
64 66 Q_D(QChartWidget);
65 67 d->m_chart->addSeries(series);
66 68 }
67 69
68 70 QChartSeries* QChartWidget::createSeries(QList<qreal> x, QList<qreal> y, QChartSeries::QChartSeriesType type)
69 71 {
70 72 Q_D(QChartWidget);
71 73 return d->m_chart->createSeries(x, y, type);
72 74 }
73 75 #include "moc_qchartwidget.cpp"
74 76
75 77 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now