aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllanguage/testtypes.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmllanguage/testtypes.h')
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h
index 003e9d06ad..758b9e2f62 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.h
+++ b/tests/auto/qml/qqmllanguage/testtypes.h
@@ -1607,6 +1607,37 @@ public:
int foo() const { return 316; }
};
+class ForeignSingleton : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(int number READ number WRITE setnumber NOTIFY numberchanged)
+public:
+ ForeignSingleton(QObject *parent = nullptr) : QObject(parent) {};
+ int number() { return m_number; }
+ void setnumber(int number) { m_number = number; }
+ static ForeignSingleton *obtain() { return new ForeignSingleton; }
+signals:
+ void numberchanged();
+private:
+ int m_number = 0;
+};
+
+class WrapperSingleton : public QObject {
+ Q_OBJECT
+ QML_NAMED_ELEMENT(ForeignSingleton)
+ QML_FOREIGN(ForeignSingleton)
+ QML_SINGLETON
+
+public:
+ static ForeignSingleton* create(QQmlEngine *, QJSEngine *) {
+ ForeignSingleton *singleton = ForeignSingleton::obtain();
+ singleton->setnumber(42);
+ return singleton;
+ }
+
+private:
+ WrapperSingleton() = default;
+};
+
void registerTypes();
#endif // TESTTYPES_H