summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2013-12-28 17:02:06 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-08 15:04:53 +0100
commitb86be10882236d269817c42daa1bc3fa49fe78af (patch)
tree5bfcc46e520daa8e0bd6c230bf83ac6360fad083 /examples
parent4d3167b97b8e48a9fcdb1c2b86467d75e7d669eb (diff)
downloadqtwebchannel-b86be10882236d269817c42daa1bc3fa49fe78af.tar.gz
Fixup and cleanup examples to make them work properly.
This fixes some regressions introduced by previous commits and ensures that the examples work as intended. While at it, the code is cleaned up a bit by using resources instead of referencing files in the source dir. Change-Id: I01da305429dcdebcb96284b7110c59f3090b2201 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/hybridshell/hybridshell.pro7
-rw-r--r--examples/hybridshell/main.cpp5
-rw-r--r--examples/hybridshell/main.qml5
-rw-r--r--examples/hybridshell/resources.qrc6
-rw-r--r--examples/qtobject/main.cpp7
-rw-r--r--examples/qtobject/main.qml5
-rw-r--r--examples/qtobject/qtobject.pro7
-rw-r--r--examples/qtobject/resources.qrc6
8 files changed, 35 insertions, 13 deletions
diff --git a/examples/hybridshell/hybridshell.pro b/examples/hybridshell/hybridshell.pro
index 2660d30..4ff38db 100644
--- a/examples/hybridshell/hybridshell.pro
+++ b/examples/hybridshell/hybridshell.pro
@@ -9,4 +9,9 @@ SOURCES += \
HEADERS += \
shell.h
-DEFINES += "SOURCE_DIR=\"\\\""$$PWD"\\\"\""
+RESOURCES += \
+ resources.qrc
+
+OTHER_FILES += \
+ main.qml \
+ index.html
diff --git a/examples/hybridshell/main.cpp b/examples/hybridshell/main.cpp
index d57966f..8c7e9b0 100644
--- a/examples/hybridshell/main.cpp
+++ b/examples/hybridshell/main.cpp
@@ -41,11 +41,10 @@
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
- qmlRegisterType<Shell>("Qt.labs", 1, 0, "HybridShell");
+ qmlRegisterType<Shell>("QtWebChannel.Examples", 1, 0, "HybridShell");
QQuickView viewer;
- viewer.engine()->addImportPath(app.applicationDirPath() + QStringLiteral("/../../src/"));
- viewer.setSource(QUrl::fromLocalFile(QStringLiteral(SOURCE_DIR) + QStringLiteral("/main.qml")));
+ viewer.setSource(QStringLiteral("qrc:/main.qml"));
viewer.show();
return app.exec();
diff --git a/examples/hybridshell/main.qml b/examples/hybridshell/main.qml
index 0dedb74..24dc729 100644
--- a/examples/hybridshell/main.qml
+++ b/examples/hybridshell/main.qml
@@ -42,6 +42,7 @@
import QtQuick 2.0
import QtWebChannel 1.0
+import QtWebChannel.Examples 1.0
import QtWebKit 3.0
import QtWebKit.experimental 1.0
@@ -66,12 +67,12 @@ Rectangle {
onInitialized: {
shell.start()
- webView.url = "index.html?webChannelBaseUrl=" + webChannel.baseUrl;
+ webView.url = "qrc:/index.html?webChannelBaseUrl=" + webChannel.baseUrl;
}
}
width: 480
- height: 800
+ height: 600
WebView {
id: webView
diff --git a/examples/hybridshell/resources.qrc b/examples/hybridshell/resources.qrc
new file mode 100644
index 0000000..b93a6b2
--- /dev/null
+++ b/examples/hybridshell/resources.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>index.html</file>
+ <file>main.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/qtobject/main.cpp b/examples/qtobject/main.cpp
index f11f4ba..4436862 100644
--- a/examples/qtobject/main.cpp
+++ b/examples/qtobject/main.cpp
@@ -41,12 +41,11 @@
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
- qmlRegisterType<TestObjectFactory>("Qt.labs", 1, 0, "TestObjectFactory");
- qmlRegisterType<TestObject>("Qt.labs", 1, 0, "TestObject");
+ qmlRegisterType<TestObjectFactory>("QtWebChannel.Examples", 1, 0, "TestObjectFactory");
+ qmlRegisterType<TestObject>("QtWebChannel.Examples", 1, 0, "TestObject");
QQuickView viewer;
- viewer.engine()->addImportPath(app.applicationDirPath() + QStringLiteral("/../../src/"));
- viewer.setSource(QUrl::fromLocalFile(QStringLiteral(SOURCE_DIR) + QStringLiteral("/main.qml")));
+ viewer.setSource(QStringLiteral("qrc:/main.qml"));
viewer.show();
return app.exec();
diff --git a/examples/qtobject/main.qml b/examples/qtobject/main.qml
index 6dd82fa..76ef3d9 100644
--- a/examples/qtobject/main.qml
+++ b/examples/qtobject/main.qml
@@ -42,6 +42,7 @@
import QtQuick 2.0
import QtWebChannel 1.0
+import QtWebChannel.Examples 1.0
import QtWebKit 3.0
import QtWebKit.experimental 1.0
@@ -63,7 +64,7 @@ Rectangle {
id: webChannel
onRawMessageReceived: {
- if (!publisher.handleRequest(rawMessage, webChannel)) {
+ if (!publisher.handleRawMessage(rawMessage)) {
console.log("unhandled request: ", rawMessage);
}
}
@@ -74,7 +75,7 @@ Rectangle {
"initialTestObject": testObject
});
- webView.url = "index.html?webChannelBaseUrl=" + webChannel.baseUrl;
+ webView.url = "qrc:/index.html?webChannelBaseUrl=" + webChannel.baseUrl;
}
}
diff --git a/examples/qtobject/qtobject.pro b/examples/qtobject/qtobject.pro
index e893d23..557603a 100644
--- a/examples/qtobject/qtobject.pro
+++ b/examples/qtobject/qtobject.pro
@@ -9,4 +9,9 @@ SOURCES += \
HEADERS += \
testobject.h
-DEFINES += "SOURCE_DIR=\"\\\""$$PWD"\\\"\""
+RESOURCES += \
+ resources.qrc
+
+OTHER_FILES += \
+ main.qml \
+ index.html
diff --git a/examples/qtobject/resources.qrc b/examples/qtobject/resources.qrc
new file mode 100644
index 0000000..b93a6b2
--- /dev/null
+++ b/examples/qtobject/resources.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>index.html</file>
+ <file>main.qml</file>
+ </qresource>
+</RCC>