aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/testtypes.h
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2012-05-11 17:37:07 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-24 05:52:32 +0200
commit4709f30b26042427b225dd164648e3f5907c9d33 (patch)
tree3edac8d14d3fb77406ef93aa2c34c42131109625 /tests/auto/qml/qqmlecmascript/testtypes.h
parent2542778d4837143a61dfcf143c32683acc8b998a (diff)
Enable binding to properties of type QJSValue.
This allows javascript objects of all types to be bound to properties declared in c++. Compared to a QVariant the primary benefit this offers is a type which functions and objects with functions can be bound to. Change-Id: Idb3313e7ff1d616ab12d44f616083c8296201f3a Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/testtypes.h')
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h
index 4740c47caa..d02f982f99 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.h
+++ b/tests/auto/qml/qqmlecmascript/testtypes.h
@@ -104,6 +104,8 @@ class MyQmlObject : public QObject
Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp)
Q_PROPERTY(int nonscriptable READ nonscriptable WRITE setNonscriptable SCRIPTABLE false)
Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty NOTIFY intChanged)
+ Q_PROPERTY(QJSValue qjsvalue READ qjsvalue WRITE setQJSValue NOTIFY qjsvalueChanged)
+ Q_PROPERTY(QJSValue qjsvalueWithReset READ qjsvalue WRITE setQJSValue RESET resetQJSValue NOTIFY qjsvalueChanged)
public:
MyQmlObject(): myinvokableObject(0), m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13), m_intProperty(0), m_buttons(0) {}
@@ -177,6 +179,9 @@ public:
};
QVariant variant() const { return m_variant; }
QJSValue qjsvalue() const { return m_qjsvalue; }
+ void setQJSValue(const QJSValue &value) { m_qjsvalue = value; emit qjsvalueChanged(); }
+ void resetQJSValue() { m_qjsvalue = QJSValue(QLatin1String("Reset!")); emit qjsvalueChanged(); }
+
Qt::MouseButtons buttons() const { return m_buttons; }
int intProperty() const { return m_intProperty; }
@@ -196,6 +201,7 @@ signals:
void signalWithQJSValue(const QJSValue &arg);
void signalWithGlobalName(int parseInt);
void intChanged();
+ void qjsvalueChanged();
public slots:
void deleteMe() { delete this; }