Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
avatarExample.h
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#ifndef AVATAREXAMPLE_P_H
5#define AVATAREXAMPLE_P_H
6
7#include <QObject>
8#include <QPixmap>
9#include <qqml.h>
10
11//![0]
12// avatarExample.h
13class AvatarExample : public QObject
14{
15 Q_OBJECT
16 Q_PROPERTY(QPixmap avatar READ avatar WRITE setAvatar NOTIFY avatarChanged)
17 QML_ELEMENT
18
19public:
20 AvatarExample(QObject *parent = nullptr)
21 : QObject(parent), m_value(100, 100)
22 {
23 m_value.fill(Qt::blue);
24 }
25
26 ~AvatarExample() {}
27
28 QPixmap avatar() const { return m_value; }
29 void setAvatar(QPixmap v) { m_value = v; emit avatarChanged(); }
30
31signals:
32 void avatarChanged();
33
34private:
35 QPixmap m_value;
36};
37//![0]
38
39#endif
int main(int argc, char *argv[])
[ctor_close]
QQmlEngine engine