aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc/snippets/qml/integrating-javascript/scarceresources/avatarExample.h
blob: 3b3f4f753748a9107403f30c40e7bacb89fb67fe (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
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#ifndef AVATAREXAMPLE_P_H
#define AVATAREXAMPLE_P_H

#include <QObject>
#include <QPixmap>
#include <qqml.h>

//![0]
// avatarExample.h
class AvatarExample : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QPixmap avatar READ avatar WRITE setAvatar NOTIFY avatarChanged)
    QML_ELEMENT

public:
    AvatarExample(QObject *parent = nullptr)
        : QObject(parent), m_value(100, 100)
    {
        m_value.fill(Qt::blue);
    }

    ~AvatarExample() {}

    QPixmap avatar() const { return m_value; }
    void setAvatar(QPixmap v) { m_value = v; emit avatarChanged(); }

signals:
    void avatarChanged();

private:
    QPixmap m_value;
};
//![0]

#endif