summaryrefslogtreecommitdiffstats
path: root/examples/charts/chartsgallery/calloutview.h
diff options
context:
space:
mode:
Diffstat (limited to 'examples/charts/chartsgallery/calloutview.h')
-rw-r--r--examples/charts/chartsgallery/calloutview.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/examples/charts/chartsgallery/calloutview.h b/examples/charts/chartsgallery/calloutview.h
new file mode 100644
index 00000000..866846a6
--- /dev/null
+++ b/examples/charts/chartsgallery/calloutview.h
@@ -0,0 +1,41 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef CALLOUTVIEW_H
+#define CALLOUTVIEW_H
+
+#include <QGraphicsView>
+
+QT_FORWARD_DECLARE_CLASS(QChart)
+QT_FORWARD_DECLARE_CLASS(QGraphicsScene)
+QT_FORWARD_DECLARE_CLASS(QGraphicsSimpleTextItem)
+QT_FORWARD_DECLARE_CLASS(QGraphicsView)
+QT_FORWARD_DECLARE_CLASS(QMouseEvent)
+QT_FORWARD_DECLARE_CLASS(QResizeEvent)
+
+class Callout;
+
+class CalloutView : public QGraphicsView
+{
+ Q_OBJECT
+public:
+ CalloutView(QWidget *parent = nullptr);
+ ~CalloutView();
+
+protected:
+ void resizeEvent(QResizeEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+
+public slots:
+ void keepCallout();
+ void tooltip(QPointF point, bool state);
+
+private:
+ QGraphicsSimpleTextItem *m_coordX = nullptr;
+ QGraphicsSimpleTextItem *m_coordY = nullptr;
+ QChart *m_chart = nullptr;
+ Callout *m_tooltip = nullptr;
+ QList<Callout *> m_callouts;
+};
+
+#endif