summaryrefslogtreecommitdiffstats
path: root/examples/dbus/remotecontrolledcar/car/car.h
blob: 5a1e199ae0446213cb98f6b9d2e39fea439f5bcd (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) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#ifndef CAR_H
#define CAR_H

#include <QGraphicsObject>
#include <QBrush>

class Car : public QGraphicsObject
{
    Q_OBJECT
public:
    Car();
    QRectF boundingRect() const override;

public slots:
    void accelerate();
    void decelerate();
    void turnLeft();
    void turnRight();

protected:
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
               QWidget *widget = nullptr) override;
    void timerEvent(QTimerEvent *event) override;

private:
    QBrush color = Qt::green;
    qreal wheelsAngle = 0; // used when applying rotation
    qreal speed = 0; // delta movement along the body axis
};

#endif // CAR_H