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 | |
12 | QT_BEGIN_NAMESPACE |
13 | class QGraphicsScene; |
14 | class QRubberBand; |
15 | QT_END_NAMESPACE |
16 | |
17 | QT_BEGIN_NAMESPACE |
18 | |
19 | class QChartViewPrivate; |
20 | |
21 | class Q_CHARTS_EXPORT QChartView : public QGraphicsView |
22 | { |
23 | Q_OBJECT |
24 | Q_ENUMS(RubberBand) |
25 | public: |
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 | |
47 | protected: |
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 | |
60 | private: |
61 | Q_DISABLE_COPY(QChartView) |
62 | }; |
63 | |
64 | QT_END_NAMESPACE |
65 | |
66 | #endif // QCHARTVIEW_H |
67 |