aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/data/cppobj.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/data/cppobj.h')
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/cppobj.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/cppobj.h b/tests/auto/qml/qmlcppcodegen/data/cppobj.h
new file mode 100644
index 0000000000..3b64c21e74
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/cppobj.h
@@ -0,0 +1,46 @@
+// Copyright (C) 2025 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef CPPOBJ_H
+#define CPPOBJ_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qdebug.h>
+#include <QtQmlIntegration/qqmlintegration.h>
+
+class CppObj : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ Q_PROPERTY(int identifier MEMBER m_identifier CONSTANT)
+
+public:
+ explicit CppObj(int identifier = -1, QObject *parent = nullptr)
+ : QObject(parent)
+ , m_identifier(identifier)
+ {
+ qDebug() << "Object created:" << m_identifier;
+ }
+
+ ~CppObj() { qDebug() << "Object destroyed:" << m_identifier; }
+
+private:
+ int m_identifier = -1;
+};
+
+class CppBridge : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ QML_SINGLETON
+
+public:
+ explicit CppBridge(QObject *parent = nullptr) : QObject{parent} {}
+
+ Q_INVOKABLE CppObj *singleObj(int identifier) const
+ {
+ return new CppObj(identifier);
+ }
+};
+
+#endif // CPPOBJ_H