summaryrefslogtreecommitdiffstats
path: root/examples/statemachine/graphicsview/padnavigator/roundrectitem.h
blob: 4c902013e47232a82ad0e75c03c719ca8750e8c2 (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#ifndef ROUNDRECTITEM_H
#define ROUNDRECTITEM_H

#include <QGraphicsObject>
#include <QLinearGradient>

//! [0]
class RoundRectItem : public QGraphicsObject
{
    Q_OBJECT
    Q_PROPERTY(bool fill READ fill WRITE setFill)
public:
    RoundRectItem(const QRectF &bounds, const QColor &color,
                  QGraphicsItem *parent = nullptr);

    QPixmap pixmap() const;
    void setPixmap(const QPixmap &pixmap);

    QRectF boundingRect() const override;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;

    bool fill() const;
    void setFill(bool fill);
//! [0]

//! [1]
private:
    QPixmap pix;
    bool fillRect;
    QRectF bounds;
    QLinearGradient gradient;
};
//! [1]

#endif // ROUNDRECTITEM_H