summaryrefslogtreecommitdiffstats
path: root/examples/charts/gallery/interactionschart.h
blob: dd0871567b8bbd3334597ff346d3e2dadfd8c863 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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