aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml/tutorials/extending-qml-advanced/advanced7-Foreign-objects-integration/happybirthdaysong.h
diff options
context:
space:
mode:
Diffstat (limited to 'examples/qml/tutorials/extending-qml-advanced/advanced7-Foreign-objects-integration/happybirthdaysong.h')
-rw-r--r--examples/qml/tutorials/extending-qml-advanced/advanced7-Foreign-objects-integration/happybirthdaysong.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/examples/qml/tutorials/extending-qml-advanced/advanced7-Foreign-objects-integration/happybirthdaysong.h b/examples/qml/tutorials/extending-qml-advanced/advanced7-Foreign-objects-integration/happybirthdaysong.h
new file mode 100644
index 0000000000..f87521a760
--- /dev/null
+++ b/examples/qml/tutorials/extending-qml-advanced/advanced7-Foreign-objects-integration/happybirthdaysong.h
@@ -0,0 +1,39 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef HAPPYBIRTHDAYSONG_H
+#define HAPPYBIRTHDAYSONG_H
+
+#include <QQmlPropertyValueSource>
+#include <QQmlProperty>
+#include <qqml.h>
+#include <QStringList>
+
+class HappyBirthdaySong : public QObject, public QQmlPropertyValueSource
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlPropertyValueSource)
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged FINAL)
+ QML_ELEMENT
+public:
+ explicit HappyBirthdaySong(QObject *parent = nullptr);
+
+ void setTarget(const QQmlProperty &) override;
+
+ QString name() const;
+ void setName(const QString &);
+
+signals:
+ void nameChanged();
+
+private slots:
+ void advance();
+
+private:
+ qsizetype m_line = -1;
+ QStringList m_lyrics;
+ QQmlProperty m_target;
+ QString m_name;
+};
+
+#endif // HAPPYBIRTHDAYSONG_H