diff options
Diffstat (limited to 'examples/qtobject')
-rw-r--r-- | examples/qtobject/index.html | 89 | ||||
-rw-r--r-- | examples/qtobject/main.cpp | 52 | ||||
-rw-r--r-- | examples/qtobject/main.qml | 78 | ||||
-rw-r--r-- | examples/qtobject/qtobject.pro | 17 | ||||
-rw-r--r-- | examples/qtobject/resources.qrc | 6 | ||||
-rw-r--r-- | examples/qtobject/testobject.cpp | 49 | ||||
-rw-r--r-- | examples/qtobject/testobject.h | 53 |
7 files changed, 0 insertions, 344 deletions
diff --git a/examples/qtobject/index.html b/examples/qtobject/index.html deleted file mode 100644 index 4987116..0000000 --- a/examples/qtobject/index.html +++ /dev/null @@ -1,89 +0,0 @@ -<html> - <head> - <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> - <script type="text/javascript"> - //BEGIN HELPER - function output(x) { - document.querySelector("#out").innerHTML += x + "\n"; - } - function createLink(label, onclick) { - var link = document.createElement("a"); - link.href = "#"; - link.onclick = onclick - link.appendChild(document.createTextNode(label)); - return link; - } - function addObject(object) { - object.timeout.connect(function() { output('timeout of object ' + object.objectName()); }); - object.sig1.connect(function(a, b, c) { - output('sig1 of object ' + object.objectName() + ": a = " + a + ", b = " + b + ", c = " + c); - }); - object.sig2.connect(function() { output('sig2 of object ' + object.objectName()); }); - object.prop1Changed.connect(function() { - // note: notify signal doesn't have the new value, so you must use direct access - output("prop1 of object " + object.objectName() + " changed, direct: " + object.prop1()); - }); - object.prop2Changed.connect(function(newVal) { - output("prop2 of object " + object.objectName() + " changed, new val: " + newVal + ", direct: " + object.prop2()); - }); - object.destroyed.connect(function() { - output("object destroyed " + object.objectName()); - }); - var container = document.getElementById("objects"); - var element = document.createElement("p"); - element.appendChild(document.createTextNode(object.objectName() + ":")); - element.appendChild(createLink("debugMe", function() { - object.debugMe('Debugging!', function(result) { output(result); }); - })); - element.appendChild(createLink("manyArgs", function() { - object.manyArgs(1, 0.5, 'asdf', function(result) { output(result); }); - })); - element.appendChild(createLink("get prop1", function() { - output(object.prop1()); - })); - element.appendChild(createLink("set prop1", function() { - object.prop1 = "Set prop1 on " + (new Date()); - })); - element.appendChild(createLink("get prop2", function() { - output(object.prop2()); - })); - element.appendChild(createLink("set prop2", function() { - object.prop2 = "Set prop2 on " + (new Date()); - })); - element.appendChild(createLink("start timer", function() { - object.startTimer(1000); - })); - element.appendChild(createLink("delete", function() { - object.deleteLater(); - })); - container.appendChild(element); - } - var createdObjects = 0; - function createObject() { - testObjectFactory.createObject("myObj" + (createdObjects++), function(createdObject) { - addObject(createdObject); - }); - } - - //END HELPER - //BEGIN SETUP - var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); - new QWebChannel(baseUrl, function(channel) { - // do stuff with registered QObjects - addObject(initialTestObject); - }); - //END SETUP - </script> - <style type="text/css"> - #objects a { - margin: 0 10px; - } - </style> - </head> - <body> - <div id="objects"></div> - <br/> - <a href="#" onclick="createObject()">Create New Object</a>. Note: Only created objects can be deleted, the initial object will stay.<br/> - <textarea id="out" style="height:80%; width: 80%"></textarea> - </body> -</html> diff --git a/examples/qtobject/main.cpp b/examples/qtobject/main.cpp deleted file mode 100644 index 4436862..0000000 --- a/examples/qtobject/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Milian Wolff <milian.wolff@kdab.com> -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QWebChannel module on Qt labs. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui/QGuiApplication> - -#include <QtQml> -#include <QQuickView> - -#include "testobject.h" - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - qmlRegisterType<TestObjectFactory>("QtWebChannel.Examples", 1, 0, "TestObjectFactory"); - qmlRegisterType<TestObject>("QtWebChannel.Examples", 1, 0, "TestObject"); - - QQuickView viewer; - viewer.setSource(QStringLiteral("qrc:/main.qml")); - viewer.show(); - - return app.exec(); -} diff --git a/examples/qtobject/main.qml b/examples/qtobject/main.qml deleted file mode 100644 index d8ec54b..0000000 --- a/examples/qtobject/main.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QWebChannel module on Qt labs. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -import QtWebChannel 1.0 -import QtWebChannel.Examples 1.0 -import QtWebKit 3.0 -import QtWebKit.experimental 1.0 - -Rectangle { - TestObjectFactory { - id: factory - WebChannel.id: "testObjectFactory" - } - TestObject { - id: testObject - objectName: "initialTestObject" - WebChannel.id: objectName - } - - WebChannel { - id: webChannel - - registeredObjects: [ - factory, - testObject - ]; - } - - width: 480 - height: 800 - - WebView { - id: webView - url: webChannel.baseUrl ? ("qrc:/index.html?webChannelBaseUrl=" + webChannel.baseUrl) : "about:blank"; - anchors.fill: parent - experimental.preferences.developerExtrasEnabled: true - } -} diff --git a/examples/qtobject/qtobject.pro b/examples/qtobject/qtobject.pro deleted file mode 100644 index 557603a..0000000 --- a/examples/qtobject/qtobject.pro +++ /dev/null @@ -1,17 +0,0 @@ -QT += qml quick - -CONFIG += warn_on - -SOURCES += \ - main.cpp \ - testobject.cpp - -HEADERS += \ - testobject.h - -RESOURCES += \ - resources.qrc - -OTHER_FILES += \ - main.qml \ - index.html diff --git a/examples/qtobject/resources.qrc b/examples/qtobject/resources.qrc deleted file mode 100644 index b93a6b2..0000000 --- a/examples/qtobject/resources.qrc +++ /dev/null @@ -1,6 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>index.html</file> - <file>main.qml</file> - </qresource> -</RCC> diff --git a/examples/qtobject/testobject.cpp b/examples/qtobject/testobject.cpp deleted file mode 100644 index 9d47e72..0000000 --- a/examples/qtobject/testobject.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "testobject.h" - -TestObject::TestObject(QObject *parent) : - QObject(parent) - , p1("Hello World") -{ - connect(&timer, SIGNAL(timeout()), this, SIGNAL(timeout())); -} - -QString TestObject::debugMe(const QString& data) -{ - qWarning() << data; - return QString("OK from %1: %2").arg(objectName()).arg(data); -} - -void TestObject::setProp1(const QString& s) -{ - p1 = s; - qWarning() << __func__ << p1; - emit sig1(1, 0.5, QStringLiteral("asdf")); - emit prop1Changed(); -} - -void TestObject::setProp2(const QString& s) -{ - p2 = s; - qWarning() << __func__ << p2; - emit sig2(); - emit prop2Changed(s); -} - -QString TestObject::manyArgs(int a, float b, const QString& c) const -{ - qDebug() << a << b << c; - return c; -} - -TestObjectFactory::TestObjectFactory(QObject* parent) - : QObject(parent) -{ - -} - -TestObject* TestObjectFactory::createObject(const QString& name) -{ - TestObject* ret = new TestObject(this); - ret->setObjectName(name); - return ret; -} diff --git a/examples/qtobject/testobject.h b/examples/qtobject/testobject.h deleted file mode 100644 index 72e57bb..0000000 --- a/examples/qtobject/testobject.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef TESTOBJECT_H -#define TESTOBJECT_H - -#include <QObject> -#include <QtDebug> -#include <QTimer> - -class TestObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString prop1 READ prop1 WRITE setProp1 NOTIFY prop1Changed) - Q_PROPERTY(QString prop2 READ prop2 WRITE setProp2 NOTIFY prop2Changed) -public: - explicit TestObject(QObject *parent = 0); - 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(); - void sig1(int a, float b, const QString& c); - void sig2(); - void prop1Changed(); - void prop2Changed(const QString& newValue); - -public slots: - void startTimer(int millis) - { - timer.start(millis); - } - - QString debugMe(const QString& data); - - QString manyArgs(int a, float b, const QString& c) const; - -private: - QString p1; - QString p2; - QTimer timer; -}; - -class TestObjectFactory : public QObject -{ - Q_OBJECT -public: - explicit TestObjectFactory(QObject* parent = 0); - - Q_INVOKABLE TestObject* createObject(const QString& name); -}; - -#endif // TESTOBJECT_H |