From 3dcb4ce965d0697a0b5e442d6bffe2936cc00f31 Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Thu, 24 Jan 2013 11:13:05 +0100 Subject: Ensure proper signal connection and property binding. When multiple signals or properties exist we must not fall into the usual javascript closure trap - we used to only use the very last signal/property of every object... Change-Id: Ief24630cc4b4ce3935207a170711f66c3ef5d805 Reviewed-by: Pierre Rossi --- examples/qtobject/qml/qtobject/index.html | 18 ++++++++++++------ examples/qtobject/testobject.cpp | 5 +++++ examples/qtobject/testobject.h | 7 ++++++- 3 files changed, 23 insertions(+), 7 deletions(-) (limited to 'examples/qtobject') diff --git a/examples/qtobject/qml/qtobject/index.html b/examples/qtobject/qml/qtobject/index.html index ab1a542..20d3572 100644 --- a/examples/qtobject/qml/qtobject/index.html +++ b/examples/qtobject/qml/qtobject/index.html @@ -18,20 +18,26 @@

TestObject 1: invoke method - Get property - Set property + Get property 1 + Set property 1 + Get property 2 + Set property 2 Timer

TestObject 2: invoke method - Get property - Set property + Get property 1 + Set property 1 + Get property 2 + Set property 2 Timer

TestObject 3: invoke method - Get property - Set property + Get property 1 + Set property 1 + Get property 2 + Set property 2 Timer


diff --git a/examples/qtobject/testobject.cpp b/examples/qtobject/testobject.cpp index 75daa8d..260f1f6 100644 --- a/examples/qtobject/testobject.cpp +++ b/examples/qtobject/testobject.cpp @@ -19,3 +19,8 @@ void TestObject::setProp1(const QString& s) qWarning() << __func__ << p1; } +void TestObject::setProp2(const QString& s) +{ + p2 = s; + qWarning() << __func__ << p2; +} diff --git a/examples/qtobject/testobject.h b/examples/qtobject/testobject.h index 992247d..fe5043d 100644 --- a/examples/qtobject/testobject.h +++ b/examples/qtobject/testobject.h @@ -8,11 +8,15 @@ class TestObject : public QObject { Q_OBJECT Q_PROPERTY(QString prop1 READ prop1 WRITE setProp1) + Q_PROPERTY(QString prop2 READ prop2 WRITE setProp2) public: explicit TestObject(QObject *parent = 0); - QString prop1() const { return p1 + objectName(); } + QString prop1() const { return "p1" + p1 + objectName(); } void setProp1(const QString& s); + QString prop2() const { return "p2" + p2 + objectName(); } + void setProp2(const QString& s); + signals: void timeout(); @@ -26,6 +30,7 @@ public slots: private: QString p1; + QString p2; QTimer timer; }; -- cgit v1.2.1