diff options
author | Pierre-Yves Siret <gr3cko@gmail.com> | 2019-12-20 01:51:39 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-01-15 14:01:08 +0000 |
commit | 43e3c21a0bad9141b6c35cc4ee4a58b4d824462a (patch) | |
tree | 4d3c1cc3e0a84eb0fa6d53acba4019a849d19102 /tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp | |
parent | 5a4ffa0de0ecc666a514ef60f0149a76d25b040d (diff) |
Add Q_GADGET Wrapper for QQmlProperty
This enable exposing a QQmlProperty as a value type to QML code.
Only object and name are exposed as a properties to keep it simple.
We might want later to expose the property of a Binding or a Behavior
as a property for complex usecases. This permits exposing it as one
self contained value instead of a pair of unrelated object and name.
Task-number: QTBUG-70964
Task-number: QTBUG-73892
Change-Id: I3a46212446f43f3a7e301943cb49d3a48c377de3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp')
-rw-r--r-- | tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 3e9047cc5a..7c75743311 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -67,6 +67,7 @@ private slots: void color(); void variant(); void locale(); + void qmlproperty(); void bindingAssignment(); void bindingRead(); @@ -360,6 +361,20 @@ void tst_qqmlvaluetypes::locale() } } +void tst_qqmlvaluetypes::qmlproperty() +{ + QQmlComponent component(&engine, testFileUrl("qmlproperty_read.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != nullptr); + + QCOMPARE(object->property("colorPropertyObject").value<QObject *>(), object); + QCOMPARE(object->property("colorPropertyName").toString(), "color"); + QCOMPARE(object->property("invalidPropertyObject").value<QObject *>(), nullptr); + QCOMPARE(object->property("invalidPropertyName").toString(), ""); + + delete object; +} + void tst_qqmlvaluetypes::sizereadonly() { { |