summaryrefslogtreecommitdiffstats
path: root/examples/charts/chartsgallery/interactionschart.h
diff options
context:
space:
mode:
Diffstat (limited to 'examples/charts/chartsgallery/interactionschart.h')
-rw-r--r--examples/charts/chartsgallery/interactionschart.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/charts/chartsgallery/interactionschart.h b/examples/charts/chartsgallery/interactionschart.h
new file mode 100644
index 00000000..dd087156
--- /dev/null
+++ b/examples/charts/chartsgallery/interactionschart.h
@@ -0,0 +1,34 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef INTERACTIONSCHART_H
+#define INTERACTIONSCHART_H
+
+#include <QChart>
+
+QT_FORWARD_DECLARE_CLASS(QLineSeries)
+
+class InteractionsChart : public QChart
+{
+ Q_OBJECT
+public:
+ explicit InteractionsChart(QGraphicsItem *parent = nullptr, Qt::WindowFlags wFlags = {}, QLineSeries *series = nullptr);
+
+public slots:
+ void clickPoint(const QPointF &point);
+
+public:
+ void handlePointMove(const QPoint &point);
+ void setPointClicked(bool clicked);
+
+private:
+ qreal distance(const QPointF &p1, const QPointF &p2);
+
+ QLineSeries *m_series = nullptr;
+ QPointF m_movingPoint;
+
+ // Boolean value to determine if an actual point in the series is clicked
+ bool m_clicked = false;
+};
+
+#endif