aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-03-15 01:00:42 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-03-15 01:00:42 +0100
commit48e2b2e6eb37f06c93c77bde89e8ae0610038a6f (patch)
tree35cd4ccef3337e48ac56cf9a16256412efa039ea /tests
parent3f4496ecea2cb1cb773c899675a6ecd0ef6183d5 (diff)
parent5b1538d1c0b408bb54786336f2e59c208686edb2 (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
index c252bba001..a456facd2f 100644
--- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
+++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
@@ -89,6 +89,7 @@ private slots:
void customValueType();
void customValueTypeInQml();
void gadgetInheritance();
+ void gadgetTemplateInheritance();
void toStringConversion();
void enumerableProperties();
void enumProperties();
@@ -1613,6 +1614,19 @@ public:
Q_INVOKABLE void functionInDerivedGadget(int value) { m_derivedProperty = value; }
};
+// QTBUG-66744: we want a Q_GADGET giving us generic type safety in C++ and property access in Qml
+template <typename T>
+struct DerivedTypedGadget : public BaseGadget
+{
+ // cannot use Q_GADGET here
+public:
+ DerivedTypedGadget() {}
+};
+
+class DerivedTypedGadgetDummyType {};
+
+Q_DECLARE_METATYPE(DerivedTypedGadget<DerivedTypedGadgetDummyType>)
+
class TypeWithCustomValueType : public QObject
{
Q_OBJECT
@@ -1657,6 +1671,21 @@ void tst_qqmlvaluetypes::gadgetInheritance()
QCOMPARE(value.property("baseProperty").toInt(), 42);
}
+void tst_qqmlvaluetypes::gadgetTemplateInheritance()
+{
+ QJSEngine engine;
+
+ QJSValue value = engine.toScriptValue(DerivedTypedGadget<DerivedTypedGadgetDummyType>());
+
+ QCOMPARE(value.property("baseProperty").toInt(), 0);
+ value.setProperty("baseProperty", 10);
+ QCOMPARE(value.property("baseProperty").toInt(), 10);
+
+ QJSValue method = value.property("functionInBaseGadget");
+ method.call(QJSValueList() << QJSValue(42));
+ QCOMPARE(value.property("baseProperty").toInt(), 42);
+}
+
struct StringLessGadget {
Q_GADGET
};