1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QCHARTVIEW_H
5#define QCHARTVIEW_H
6
7#include <QtCharts/QAbstractAxis>
8#include <QtCharts/QAbstractSeries>
9#include <QtCharts/QChart>
10#include <QtWidgets/QGraphicsView>
11
12QT_BEGIN_NAMESPACE
13class QGraphicsScene;
14class QRubberBand;
15QT_END_NAMESPACE
16
17QT_BEGIN_NAMESPACE
18
19class QChartViewPrivate;
20
21class Q_CHARTS_EXPORT QChartView : public QGraphicsView
22{
23 Q_OBJECT
24 Q_ENUMS(RubberBand)
25public:
26
27 enum RubberBand {
28 NoRubberBand = 0x0,
29 VerticalRubberBand = 0x1,
30 HorizontalRubberBand = 0x2,
31 RectangleRubberBand = 0x3,
32 ClickThroughRubberBand = 0x80
33 };
34
35 Q_DECLARE_FLAGS(RubberBands, RubberBand)
36
37 explicit QChartView(QWidget *parent = nullptr);
38 explicit QChartView(QChart *chart, QWidget *parent = nullptr);
39 ~QChartView();
40
41 void setRubberBand(const RubberBands &rubberBands);
42 RubberBands rubberBand() const;
43
44 QChart *chart() const;
45 void setChart(QChart *chart);
46
47protected:
48 void resizeEvent(QResizeEvent *event) override;
49 void mousePressEvent(QMouseEvent *event) override;
50 void mouseMoveEvent(QMouseEvent *event) override;
51 void mouseReleaseEvent(QMouseEvent *event) override;
52#ifdef Q_OS_MACOS
53#if QT_CONFIG(wheelevent)
54 void wheelEvent(QWheelEvent *event) override;
55#endif
56#endif
57
58 QScopedPointer<QChartViewPrivate> d_ptr;
59
60private:
61 Q_DISABLE_COPY(QChartView)
62};
63
64QT_END_NAMESPACE
65
66#endif // QCHARTVIEW_H
67

source code of qtcharts/src/charts/qchartview.h