diff options
author | Kai Dohmen <psykai1993@googlemail.com> | 2016-04-11 19:38:50 +0200 |
---|---|---|
committer | Milian Wolff <milian.wolff@kdab.com> | 2016-06-21 09:50:33 +0000 |
commit | f48e8c9711fbeb350ccf70f852ce3732844d4287 (patch) | |
tree | 43756259e8794b89801cdc2aa936840af92c5d98 /tests/auto/webchannel/tst_webchannel.h | |
parent | 3be67a7799aa1960d459548a43ddf54044f80ec1 (diff) | |
download | qtwebchannel-f48e8c9711fbeb350ccf70f852ce3732844d4287.tar.gz |
Make passing objects from website to server possible
If you get an object from the server and want to pass it back to the
server via a function the id of the object is passed instead of the
whole json object. On the server side QMetaObjectPublisher::invokeMethod
now looks up the object in QMetaObjectPublisher::wrappedObjects by the
passed object-id.
Task-number: QTBUG-50075
Change-Id: Id0df2dfaa79bcba12ca48391ae7537ac1a086898
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Diffstat (limited to 'tests/auto/webchannel/tst_webchannel.h')
-rw-r--r-- | tests/auto/webchannel/tst_webchannel.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/webchannel/tst_webchannel.h b/tests/auto/webchannel/tst_webchannel.h index 13294c2..5a9fa11 100644 --- a/tests/auto/webchannel/tst_webchannel.h +++ b/tests/auto/webchannel/tst_webchannel.h @@ -73,11 +73,13 @@ class TestObject : public QObject Q_PROPERTY(int asdf READ asdf NOTIFY asdfChanged) Q_PROPERTY(QString bar READ bar NOTIFY theBarHasChanged) Q_PROPERTY(QObject * objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectPropertyChanged) + Q_PROPERTY(TestObject * returnedObject READ returnedObject WRITE setReturnedObject NOTIFY returnedObjectChanged) public: explicit TestObject(QObject *parent = 0) : QObject(parent) , mObjectProperty(0) + , mReturnedObject(Q_NULLPTR) { } enum Foo { @@ -94,6 +96,11 @@ public: return mObjectProperty; } + TestObject *returnedObject() const + { + return mReturnedObject; + } + Q_INVOKABLE void method1() {} protected: @@ -108,11 +115,18 @@ signals: void asdfChanged(); void theBarHasChanged(); void objectPropertyChanged(); + void returnedObjectChanged(); public slots: void slot1() {} void slot2(const QString&) {} + void setReturnedObject(TestObject *obj) + { + mReturnedObject = obj; + emit returnedObjectChanged(); + } + void setObjectProperty(QObject *object) { mObjectProperty = object; @@ -127,6 +141,7 @@ private slots: public: QObject *mObjectProperty; + TestObject *mReturnedObject; }; class BenchObject : public QObject @@ -264,6 +279,7 @@ private slots: void testSetPropertyConversion(); void testDisconnect(); void testWrapRegisteredObject(); + void testPassWrappedObjectBack(); void testInfiniteRecursion(); void benchClassInfo(); |