blob: f06c3209c4ac70a1b0251128c3861fb3a07ccb58 (
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
35
36
37
38
39
40
41
42
43
|
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DISPLAYWIDGET_H
#define DISPLAYWIDGET_H
#include <QColor>
#include <QHash>
#include <QPainterPath>
#include <QWidget>
//! [DisplayWidget class definition]
class DisplayWidget : public QWidget
{
Q_OBJECT
public:
enum Shape { House = 0, Car = 1 };
enum Background { Sky = 0, Trees = 1, Road = 2 };
DisplayWidget(QWidget *parent = 0);
QColor color() const;
void paint(QPainter &painter);
public slots:
void setBackground(Background background);
void setColor(const QColor &color);
void setShape(Shape shape);
protected:
void paintEvent(QPaintEvent *event) override;
private:
Background background;
QColor shapeColor;
Shape shape;
QHash<Shape,QPainterPath> shapeMap;
QPainterPath moon;
QPainterPath tree;
};
//! [DisplayWidget class definition]
#endif
|