displaywidget.h Example File
svggenerator/displaywidget.h
#ifndef DISPLAYWIDGET_H
#define DISPLAYWIDGET_H
#include <QColor>
#include <QHash>
#include <QWidget>
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;
};
#endif